GCC Code Coverage Report


Directory: ./
File: Python/Python-ast.c
Date: 2022-06-27 09:02:04
Exec Total Coverage
Lines: 2546 8052 31.6%
Functions: 101 149 67.8%
Branches: 1463 6355 23.0%

Line Branch Exec Source
1 // File automatically generated by Parser/asdl_c.py.
2
3 #include "Python.h"
4 #include "pycore_ast.h"
5 #include "pycore_ast_state.h" // struct ast_state
6 #include "pycore_ceval.h" // _Py_EnterRecursiveCall
7 #include "pycore_interp.h" // _PyInterpreterState.ast
8 #include "pycore_pystate.h" // _PyInterpreterState_GET()
9 #include "structmember.h"
10 #include <stddef.h>
11
12 // Forward declaration
13 static int init_types(struct ast_state *state);
14
15 static struct ast_state*
16 47664 get_ast_state(void)
17 {
18 47664 PyInterpreterState *interp = _PyInterpreterState_GET();
19 47664 struct ast_state *state = &interp->ast;
20
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 47664 times.
47664 if (!init_types(state)) {
21 return NULL;
22 }
23 47664 return state;
24 }
25
26 3404 void _PyAST_Fini(PyInterpreterState *interp)
27 {
28 3404 struct ast_state *state = &interp->ast;
29
30
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->AST_type);
31
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Add_singleton);
32
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Add_type);
33
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->And_singleton);
34
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->And_type);
35
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->AnnAssign_type);
36
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Assert_type);
37
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Assign_type);
38
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->AsyncFor_type);
39
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->AsyncFunctionDef_type);
40
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->AsyncWith_type);
41
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Attribute_type);
42
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->AugAssign_type);
43
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Await_type);
44
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->BinOp_type);
45
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->BitAnd_singleton);
46
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->BitAnd_type);
47
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->BitOr_singleton);
48
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->BitOr_type);
49
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->BitXor_singleton);
50
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->BitXor_type);
51
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->BoolOp_type);
52
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Break_type);
53
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Call_type);
54
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->ClassDef_type);
55
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Compare_type);
56
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Constant_type);
57
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Continue_type);
58
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Del_singleton);
59
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Del_type);
60
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Delete_type);
61
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->DictComp_type);
62
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Dict_type);
63
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Div_singleton);
64
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Div_type);
65
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Eq_singleton);
66
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Eq_type);
67
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->ExceptHandler_type);
68
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Expr_type);
69
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Expression_type);
70
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->FloorDiv_singleton);
71
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->FloorDiv_type);
72
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->For_type);
73
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->FormattedValue_type);
74
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->FunctionDef_type);
75
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->FunctionType_type);
76
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->GeneratorExp_type);
77
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Global_type);
78
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->GtE_singleton);
79
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->GtE_type);
80
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Gt_singleton);
81
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Gt_type);
82
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->IfExp_type);
83
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->If_type);
84
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->ImportFrom_type);
85
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Import_type);
86
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->In_singleton);
87
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->In_type);
88
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Interactive_type);
89
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Invert_singleton);
90
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Invert_type);
91
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->IsNot_singleton);
92
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->IsNot_type);
93
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Is_singleton);
94
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Is_type);
95
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->JoinedStr_type);
96
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->LShift_singleton);
97
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->LShift_type);
98
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Lambda_type);
99
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->ListComp_type);
100
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->List_type);
101
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Load_singleton);
102
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Load_type);
103
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->LtE_singleton);
104
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->LtE_type);
105
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Lt_singleton);
106
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Lt_type);
107
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->MatMult_singleton);
108
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->MatMult_type);
109
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->MatchAs_type);
110
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->MatchClass_type);
111
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->MatchMapping_type);
112
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->MatchOr_type);
113
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->MatchSequence_type);
114
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->MatchSingleton_type);
115
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->MatchStar_type);
116
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->MatchValue_type);
117
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Match_type);
118
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Mod_singleton);
119
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Mod_type);
120
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Module_type);
121
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Mult_singleton);
122
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Mult_type);
123
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Name_type);
124
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->NamedExpr_type);
125
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Nonlocal_type);
126
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->NotEq_singleton);
127
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->NotEq_type);
128
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->NotIn_singleton);
129
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->NotIn_type);
130
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Not_singleton);
131
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Not_type);
132
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Or_singleton);
133
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Or_type);
134
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Pass_type);
135
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Pow_singleton);
136
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Pow_type);
137
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->RShift_singleton);
138
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->RShift_type);
139
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Raise_type);
140
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Return_type);
141
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->SetComp_type);
142
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Set_type);
143
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Slice_type);
144
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Starred_type);
145
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Store_singleton);
146
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Store_type);
147
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Sub_singleton);
148
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Sub_type);
149
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Subscript_type);
150
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->TryStar_type);
151
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Try_type);
152
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Tuple_type);
153
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->TypeIgnore_type);
154
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->UAdd_singleton);
155
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->UAdd_type);
156
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->USub_singleton);
157
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->USub_type);
158
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->UnaryOp_type);
159
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->While_type);
160
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->With_type);
161
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->YieldFrom_type);
162
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->Yield_type);
163
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->__dict__);
164
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->__doc__);
165
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->__match_args__);
166
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->__module__);
167
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->_attributes);
168
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->_fields);
169
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->alias_type);
170
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->annotation);
171
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->arg);
172
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->arg_type);
173
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->args);
174
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->argtypes);
175
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->arguments_type);
176
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->asname);
177
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->ast);
178
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->attr);
179
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->bases);
180
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->body);
181
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->boolop_type);
182
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->cases);
183
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->cause);
184
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->cls);
185
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->cmpop_type);
186
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->col_offset);
187
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->comparators);
188
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->comprehension_type);
189
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->context_expr);
190
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->conversion);
191
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->ctx);
192
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->decorator_list);
193
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->defaults);
194
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->elt);
195
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->elts);
196
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->end_col_offset);
197
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->end_lineno);
198
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->exc);
199
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->excepthandler_type);
200
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->expr_context_type);
201
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->expr_type);
202
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->finalbody);
203
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->format_spec);
204
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->func);
205
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->generators);
206
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->guard);
207
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->handlers);
208
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->id);
209
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->ifs);
210
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->is_async);
211
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->items);
212
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->iter);
213
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->key);
214
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->keys);
215
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->keyword_type);
216
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->keywords);
217
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->kind);
218
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->kw_defaults);
219
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->kwarg);
220
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->kwd_attrs);
221
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->kwd_patterns);
222
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->kwonlyargs);
223
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->left);
224
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->level);
225
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->lineno);
226
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->lower);
227
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->match_case_type);
228
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->mod_type);
229
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->module);
230
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->msg);
231
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->name);
232
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->names);
233
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->op);
234
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->operand);
235
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->operator_type);
236
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->ops);
237
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->optional_vars);
238
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->orelse);
239
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->pattern);
240
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->pattern_type);
241
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->patterns);
242
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->posonlyargs);
243
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->rest);
244
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->returns);
245
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->right);
246
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->simple);
247
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->slice);
248
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->step);
249
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->stmt_type);
250
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->subject);
251
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->tag);
252
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->target);
253
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->targets);
254
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->test);
255
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->type);
256
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->type_comment);
257
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->type_ignore_type);
258
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->type_ignores);
259
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->unaryop_type);
260
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->upper);
261
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->value);
262
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->values);
263
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->vararg);
264
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 2609 times.
3404 Py_CLEAR(state->withitem_type);
265
266 #if !defined(NDEBUG)
267 state->initialized = -1;
268 #else
269 3404 state->initialized = 0;
270 #endif
271 3404 }
272
273 795 static int init_identifiers(struct ast_state *state)
274 {
275
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->__dict__ = PyUnicode_InternFromString("__dict__")) == NULL) return 0;
276
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->__doc__ = PyUnicode_InternFromString("__doc__")) == NULL) return 0;
277
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->__match_args__ = PyUnicode_InternFromString("__match_args__")) == NULL) return 0;
278
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->__module__ = PyUnicode_InternFromString("__module__")) == NULL) return 0;
279
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->_attributes = PyUnicode_InternFromString("_attributes")) == NULL) return 0;
280
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->_fields = PyUnicode_InternFromString("_fields")) == NULL) return 0;
281
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->annotation = PyUnicode_InternFromString("annotation")) == NULL) return 0;
282
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->arg = PyUnicode_InternFromString("arg")) == NULL) return 0;
283
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->args = PyUnicode_InternFromString("args")) == NULL) return 0;
284
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->argtypes = PyUnicode_InternFromString("argtypes")) == NULL) return 0;
285
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->asname = PyUnicode_InternFromString("asname")) == NULL) return 0;
286
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->ast = PyUnicode_InternFromString("ast")) == NULL) return 0;
287
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->attr = PyUnicode_InternFromString("attr")) == NULL) return 0;
288
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->bases = PyUnicode_InternFromString("bases")) == NULL) return 0;
289
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->body = PyUnicode_InternFromString("body")) == NULL) return 0;
290
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->cases = PyUnicode_InternFromString("cases")) == NULL) return 0;
291
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->cause = PyUnicode_InternFromString("cause")) == NULL) return 0;
292
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->cls = PyUnicode_InternFromString("cls")) == NULL) return 0;
293
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->col_offset = PyUnicode_InternFromString("col_offset")) == NULL) return 0;
294
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->comparators = PyUnicode_InternFromString("comparators")) == NULL) return 0;
295
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->context_expr = PyUnicode_InternFromString("context_expr")) == NULL) return 0;
296
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->conversion = PyUnicode_InternFromString("conversion")) == NULL) return 0;
297
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->ctx = PyUnicode_InternFromString("ctx")) == NULL) return 0;
298
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->decorator_list = PyUnicode_InternFromString("decorator_list")) == NULL) return 0;
299
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->defaults = PyUnicode_InternFromString("defaults")) == NULL) return 0;
300
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->elt = PyUnicode_InternFromString("elt")) == NULL) return 0;
301
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->elts = PyUnicode_InternFromString("elts")) == NULL) return 0;
302
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->end_col_offset = PyUnicode_InternFromString("end_col_offset")) == NULL) return 0;
303
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->end_lineno = PyUnicode_InternFromString("end_lineno")) == NULL) return 0;
304
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->exc = PyUnicode_InternFromString("exc")) == NULL) return 0;
305
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->finalbody = PyUnicode_InternFromString("finalbody")) == NULL) return 0;
306
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->format_spec = PyUnicode_InternFromString("format_spec")) == NULL) return 0;
307
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->func = PyUnicode_InternFromString("func")) == NULL) return 0;
308
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->generators = PyUnicode_InternFromString("generators")) == NULL) return 0;
309
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->guard = PyUnicode_InternFromString("guard")) == NULL) return 0;
310
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->handlers = PyUnicode_InternFromString("handlers")) == NULL) return 0;
311
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->id = PyUnicode_InternFromString("id")) == NULL) return 0;
312
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->ifs = PyUnicode_InternFromString("ifs")) == NULL) return 0;
313
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->is_async = PyUnicode_InternFromString("is_async")) == NULL) return 0;
314
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->items = PyUnicode_InternFromString("items")) == NULL) return 0;
315
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->iter = PyUnicode_InternFromString("iter")) == NULL) return 0;
316
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->key = PyUnicode_InternFromString("key")) == NULL) return 0;
317
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->keys = PyUnicode_InternFromString("keys")) == NULL) return 0;
318
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->keywords = PyUnicode_InternFromString("keywords")) == NULL) return 0;
319
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->kind = PyUnicode_InternFromString("kind")) == NULL) return 0;
320
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->kw_defaults = PyUnicode_InternFromString("kw_defaults")) == NULL) return 0;
321
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->kwarg = PyUnicode_InternFromString("kwarg")) == NULL) return 0;
322
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->kwd_attrs = PyUnicode_InternFromString("kwd_attrs")) == NULL) return 0;
323
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->kwd_patterns = PyUnicode_InternFromString("kwd_patterns")) == NULL) return 0;
324
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->kwonlyargs = PyUnicode_InternFromString("kwonlyargs")) == NULL) return 0;
325
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->left = PyUnicode_InternFromString("left")) == NULL) return 0;
326
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->level = PyUnicode_InternFromString("level")) == NULL) return 0;
327
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->lineno = PyUnicode_InternFromString("lineno")) == NULL) return 0;
328
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->lower = PyUnicode_InternFromString("lower")) == NULL) return 0;
329
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->module = PyUnicode_InternFromString("module")) == NULL) return 0;
330
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->msg = PyUnicode_InternFromString("msg")) == NULL) return 0;
331
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->name = PyUnicode_InternFromString("name")) == NULL) return 0;
332
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->names = PyUnicode_InternFromString("names")) == NULL) return 0;
333
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->op = PyUnicode_InternFromString("op")) == NULL) return 0;
334
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->operand = PyUnicode_InternFromString("operand")) == NULL) return 0;
335
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->ops = PyUnicode_InternFromString("ops")) == NULL) return 0;
336
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->optional_vars = PyUnicode_InternFromString("optional_vars")) == NULL) return 0;
337
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->orelse = PyUnicode_InternFromString("orelse")) == NULL) return 0;
338
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->pattern = PyUnicode_InternFromString("pattern")) == NULL) return 0;
339
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->patterns = PyUnicode_InternFromString("patterns")) == NULL) return 0;
340
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->posonlyargs = PyUnicode_InternFromString("posonlyargs")) == NULL) return 0;
341
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->rest = PyUnicode_InternFromString("rest")) == NULL) return 0;
342
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->returns = PyUnicode_InternFromString("returns")) == NULL) return 0;
343
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->right = PyUnicode_InternFromString("right")) == NULL) return 0;
344
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->simple = PyUnicode_InternFromString("simple")) == NULL) return 0;
345
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->slice = PyUnicode_InternFromString("slice")) == NULL) return 0;
346
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->step = PyUnicode_InternFromString("step")) == NULL) return 0;
347
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->subject = PyUnicode_InternFromString("subject")) == NULL) return 0;
348
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->tag = PyUnicode_InternFromString("tag")) == NULL) return 0;
349
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->target = PyUnicode_InternFromString("target")) == NULL) return 0;
350
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->targets = PyUnicode_InternFromString("targets")) == NULL) return 0;
351
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->test = PyUnicode_InternFromString("test")) == NULL) return 0;
352
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->type = PyUnicode_InternFromString("type")) == NULL) return 0;
353
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->type_comment = PyUnicode_InternFromString("type_comment")) == NULL) return 0;
354
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->type_ignores = PyUnicode_InternFromString("type_ignores")) == NULL) return 0;
355
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->upper = PyUnicode_InternFromString("upper")) == NULL) return 0;
356
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->value = PyUnicode_InternFromString("value")) == NULL) return 0;
357
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->values = PyUnicode_InternFromString("values")) == NULL) return 0;
358
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if ((state->vararg = PyUnicode_InternFromString("vararg")) == NULL) return 0;
359 795 return 1;
360 };
361
362 GENERATE_ASDL_SEQ_CONSTRUCTOR(mod, mod_ty)
363 GENERATE_ASDL_SEQ_CONSTRUCTOR(stmt, stmt_ty)
364
8/12
✓ Branch 0 taken 848301 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 319517 times.
✓ Branch 3 taken 528784 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 319517 times.
✓ Branch 7 taken 319517 times.
✓ Branch 8 taken 528784 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 848301 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 848301 times.
848301 GENERATE_ASDL_SEQ_CONSTRUCTOR(expr, expr_ty)
365 GENERATE_ASDL_SEQ_CONSTRUCTOR(comprehension, comprehension_ty)
366 GENERATE_ASDL_SEQ_CONSTRUCTOR(excepthandler, excepthandler_ty)
367 GENERATE_ASDL_SEQ_CONSTRUCTOR(arguments, arguments_ty)
368
8/12
✓ Branch 0 taken 783687 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21643 times.
✓ Branch 3 taken 762044 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 21643 times.
✓ Branch 7 taken 21643 times.
✓ Branch 8 taken 762044 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 783687 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 783687 times.
783687 GENERATE_ASDL_SEQ_CONSTRUCTOR(arg, arg_ty)
369
6/12
✓ Branch 0 taken 64001 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 64001 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 64001 times.
✓ Branch 7 taken 64001 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 64001 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 64001 times.
64001 GENERATE_ASDL_SEQ_CONSTRUCTOR(keyword, keyword_ty)
370 GENERATE_ASDL_SEQ_CONSTRUCTOR(alias, alias_ty)
371 GENERATE_ASDL_SEQ_CONSTRUCTOR(withitem, withitem_ty)
372 GENERATE_ASDL_SEQ_CONSTRUCTOR(match_case, match_case_ty)
373 GENERATE_ASDL_SEQ_CONSTRUCTOR(pattern, pattern_ty)
374 GENERATE_ASDL_SEQ_CONSTRUCTOR(type_ignore, type_ignore_ty)
375
376 static PyObject* ast2obj_mod(struct ast_state *state, void*);
377 static const char * const Module_fields[]={
378 "body",
379 "type_ignores",
380 };
381 static const char * const Interactive_fields[]={
382 "body",
383 };
384 static const char * const Expression_fields[]={
385 "body",
386 };
387 static const char * const FunctionType_fields[]={
388 "argtypes",
389 "returns",
390 };
391 static const char * const stmt_attributes[] = {
392 "lineno",
393 "col_offset",
394 "end_lineno",
395 "end_col_offset",
396 };
397 static PyObject* ast2obj_stmt(struct ast_state *state, void*);
398 static const char * const FunctionDef_fields[]={
399 "name",
400 "args",
401 "body",
402 "decorator_list",
403 "returns",
404 "type_comment",
405 };
406 static const char * const AsyncFunctionDef_fields[]={
407 "name",
408 "args",
409 "body",
410 "decorator_list",
411 "returns",
412 "type_comment",
413 };
414 static const char * const ClassDef_fields[]={
415 "name",
416 "bases",
417 "keywords",
418 "body",
419 "decorator_list",
420 };
421 static const char * const Return_fields[]={
422 "value",
423 };
424 static const char * const Delete_fields[]={
425 "targets",
426 };
427 static const char * const Assign_fields[]={
428 "targets",
429 "value",
430 "type_comment",
431 };
432 static const char * const AugAssign_fields[]={
433 "target",
434 "op",
435 "value",
436 };
437 static const char * const AnnAssign_fields[]={
438 "target",
439 "annotation",
440 "value",
441 "simple",
442 };
443 static const char * const For_fields[]={
444 "target",
445 "iter",
446 "body",
447 "orelse",
448 "type_comment",
449 };
450 static const char * const AsyncFor_fields[]={
451 "target",
452 "iter",
453 "body",
454 "orelse",
455 "type_comment",
456 };
457 static const char * const While_fields[]={
458 "test",
459 "body",
460 "orelse",
461 };
462 static const char * const If_fields[]={
463 "test",
464 "body",
465 "orelse",
466 };
467 static const char * const With_fields[]={
468 "items",
469 "body",
470 "type_comment",
471 };
472 static const char * const AsyncWith_fields[]={
473 "items",
474 "body",
475 "type_comment",
476 };
477 static const char * const Match_fields[]={
478 "subject",
479 "cases",
480 };
481 static const char * const Raise_fields[]={
482 "exc",
483 "cause",
484 };
485 static const char * const Try_fields[]={
486 "body",
487 "handlers",
488 "orelse",
489 "finalbody",
490 };
491 static const char * const TryStar_fields[]={
492 "body",
493 "handlers",
494 "orelse",
495 "finalbody",
496 };
497 static const char * const Assert_fields[]={
498 "test",
499 "msg",
500 };
501 static const char * const Import_fields[]={
502 "names",
503 };
504 static const char * const ImportFrom_fields[]={
505 "module",
506 "names",
507 "level",
508 };
509 static const char * const Global_fields[]={
510 "names",
511 };
512 static const char * const Nonlocal_fields[]={
513 "names",
514 };
515 static const char * const Expr_fields[]={
516 "value",
517 };
518 static const char * const expr_attributes[] = {
519 "lineno",
520 "col_offset",
521 "end_lineno",
522 "end_col_offset",
523 };
524 static PyObject* ast2obj_expr(struct ast_state *state, void*);
525 static const char * const BoolOp_fields[]={
526 "op",
527 "values",
528 };
529 static const char * const NamedExpr_fields[]={
530 "target",
531 "value",
532 };
533 static const char * const BinOp_fields[]={
534 "left",
535 "op",
536 "right",
537 };
538 static const char * const UnaryOp_fields[]={
539 "op",
540 "operand",
541 };
542 static const char * const Lambda_fields[]={
543 "args",
544 "body",
545 };
546 static const char * const IfExp_fields[]={
547 "test",
548 "body",
549 "orelse",
550 };
551 static const char * const Dict_fields[]={
552 "keys",
553 "values",
554 };
555 static const char * const Set_fields[]={
556 "elts",
557 };
558 static const char * const ListComp_fields[]={
559 "elt",
560 "generators",
561 };
562 static const char * const SetComp_fields[]={
563 "elt",
564 "generators",
565 };
566 static const char * const DictComp_fields[]={
567 "key",
568 "value",
569 "generators",
570 };
571 static const char * const GeneratorExp_fields[]={
572 "elt",
573 "generators",
574 };
575 static const char * const Await_fields[]={
576 "value",
577 };
578 static const char * const Yield_fields[]={
579 "value",
580 };
581 static const char * const YieldFrom_fields[]={
582 "value",
583 };
584 static const char * const Compare_fields[]={
585 "left",
586 "ops",
587 "comparators",
588 };
589 static const char * const Call_fields[]={
590 "func",
591 "args",
592 "keywords",
593 };
594 static const char * const FormattedValue_fields[]={
595 "value",
596 "conversion",
597 "format_spec",
598 };
599 static const char * const JoinedStr_fields[]={
600 "values",
601 };
602 static const char * const Constant_fields[]={
603 "value",
604 "kind",
605 };
606 static const char * const Attribute_fields[]={
607 "value",
608 "attr",
609 "ctx",
610 };
611 static const char * const Subscript_fields[]={
612 "value",
613 "slice",
614 "ctx",
615 };
616 static const char * const Starred_fields[]={
617 "value",
618 "ctx",
619 };
620 static const char * const Name_fields[]={
621 "id",
622 "ctx",
623 };
624 static const char * const List_fields[]={
625 "elts",
626 "ctx",
627 };
628 static const char * const Tuple_fields[]={
629 "elts",
630 "ctx",
631 };
632 static const char * const Slice_fields[]={
633 "lower",
634 "upper",
635 "step",
636 };
637 static PyObject* ast2obj_expr_context(struct ast_state *state, expr_context_ty);
638 static PyObject* ast2obj_boolop(struct ast_state *state, boolop_ty);
639 static PyObject* ast2obj_operator(struct ast_state *state, operator_ty);
640 static PyObject* ast2obj_unaryop(struct ast_state *state, unaryop_ty);
641 static PyObject* ast2obj_cmpop(struct ast_state *state, cmpop_ty);
642 static PyObject* ast2obj_comprehension(struct ast_state *state, void*);
643 static const char * const comprehension_fields[]={
644 "target",
645 "iter",
646 "ifs",
647 "is_async",
648 };
649 static const char * const excepthandler_attributes[] = {
650 "lineno",
651 "col_offset",
652 "end_lineno",
653 "end_col_offset",
654 };
655 static PyObject* ast2obj_excepthandler(struct ast_state *state, void*);
656 static const char * const ExceptHandler_fields[]={
657 "type",
658 "name",
659 "body",
660 };
661 static PyObject* ast2obj_arguments(struct ast_state *state, void*);
662 static const char * const arguments_fields[]={
663 "posonlyargs",
664 "args",
665 "vararg",
666 "kwonlyargs",
667 "kw_defaults",
668 "kwarg",
669 "defaults",
670 };
671 static PyObject* ast2obj_arg(struct ast_state *state, void*);
672 static const char * const arg_attributes[] = {
673 "lineno",
674 "col_offset",
675 "end_lineno",
676 "end_col_offset",
677 };
678 static const char * const arg_fields[]={
679 "arg",
680 "annotation",
681 "type_comment",
682 };
683 static PyObject* ast2obj_keyword(struct ast_state *state, void*);
684 static const char * const keyword_attributes[] = {
685 "lineno",
686 "col_offset",
687 "end_lineno",
688 "end_col_offset",
689 };
690 static const char * const keyword_fields[]={
691 "arg",
692 "value",
693 };
694 static PyObject* ast2obj_alias(struct ast_state *state, void*);
695 static const char * const alias_attributes[] = {
696 "lineno",
697 "col_offset",
698 "end_lineno",
699 "end_col_offset",
700 };
701 static const char * const alias_fields[]={
702 "name",
703 "asname",
704 };
705 static PyObject* ast2obj_withitem(struct ast_state *state, void*);
706 static const char * const withitem_fields[]={
707 "context_expr",
708 "optional_vars",
709 };
710 static PyObject* ast2obj_match_case(struct ast_state *state, void*);
711 static const char * const match_case_fields[]={
712 "pattern",
713 "guard",
714 "body",
715 };
716 static const char * const pattern_attributes[] = {
717 "lineno",
718 "col_offset",
719 "end_lineno",
720 "end_col_offset",
721 };
722 static PyObject* ast2obj_pattern(struct ast_state *state, void*);
723 static const char * const MatchValue_fields[]={
724 "value",
725 };
726 static const char * const MatchSingleton_fields[]={
727 "value",
728 };
729 static const char * const MatchSequence_fields[]={
730 "patterns",
731 };
732 static const char * const MatchMapping_fields[]={
733 "keys",
734 "patterns",
735 "rest",
736 };
737 static const char * const MatchClass_fields[]={
738 "cls",
739 "patterns",
740 "kwd_attrs",
741 "kwd_patterns",
742 };
743 static const char * const MatchStar_fields[]={
744 "name",
745 };
746 static const char * const MatchAs_fields[]={
747 "pattern",
748 "name",
749 };
750 static const char * const MatchOr_fields[]={
751 "patterns",
752 };
753 static PyObject* ast2obj_type_ignore(struct ast_state *state, void*);
754 static const char * const TypeIgnore_fields[]={
755 "lineno",
756 "tag",
757 };
758
759
760
761 typedef struct {
762 PyObject_HEAD
763 PyObject *dict;
764 } AST_object;
765
766 static void
767 509128 ast_dealloc(AST_object *self)
768 {
769 /* bpo-31095: UnTrack is needed before calling any callbacks */
770 509128 PyTypeObject *tp = Py_TYPE(self);
771 509128 PyObject_GC_UnTrack(self);
772
2/2
✓ Branch 0 taken 478606 times.
✓ Branch 1 taken 30522 times.
509128 Py_CLEAR(self->dict);
773 509128 freefunc free_func = PyType_GetSlot(tp, Py_tp_free);
774 assert(free_func != NULL);
775 509128 free_func(self);
776 509128 Py_DECREF(tp);
777 509128 }
778
779 static int
780 2327718 ast_traverse(AST_object *self, visitproc visit, void *arg)
781 {
782
2/4
✓ Branch 1 taken 2327718 times.
✗ Branch 2 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 2327718 times.
2327718 Py_VISIT(Py_TYPE(self));
783
3/4
✓ Branch 0 taken 1913556 times.
✓ Branch 1 taken 414162 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1913556 times.
2327718 Py_VISIT(self->dict);
784 2327718 return 0;
785 }
786
787 static int
788 792 ast_clear(AST_object *self)
789 {
790
2/2
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 220 times.
792 Py_CLEAR(self->dict);
791 792 return 0;
792 }
793
794 static int
795 13936 ast_type_init(PyObject *self, PyObject *args, PyObject *kw)
796 {
797 13936 struct ast_state *state = get_ast_state();
798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13936 times.
13936 if (state == NULL) {
799 return -1;
800 }
801
802 13936 Py_ssize_t i, numfields = 0;
803 13936 int res = -1;
804 PyObject *key, *value, *fields;
805
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 13936 times.
13936 if (_PyObject_LookupAttr((PyObject*)Py_TYPE(self), state->_fields, &fields) < 0) {
806 goto cleanup;
807 }
808
1/2
✓ Branch 0 taken 13936 times.
✗ Branch 1 not taken.
13936 if (fields) {
809 13936 numfields = PySequence_Size(fields);
810
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13936 times.
13936 if (numfields == -1) {
811 goto cleanup;
812 }
813 }
814
815 13936 res = 0; /* if no error occurs, this stays 0 to the end */
816
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 13936 times.
13936 if (numfields < PyTuple_GET_SIZE(args)) {
817 PyErr_Format(PyExc_TypeError, "%.400s constructor takes at most "
818 "%zd positional argument%s",
819 _PyType_Name(Py_TYPE(self)),
820 numfields, numfields == 1 ? "" : "s");
821 res = -1;
822 goto cleanup;
823 }
824
2/2
✓ Branch 1 taken 22 times.
✓ Branch 2 taken 13936 times.
13958 for (i = 0; i < PyTuple_GET_SIZE(args); i++) {
825 /* cannot be reached when fields is NULL */
826 22 PyObject *name = PySequence_GetItem(fields, i);
827
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if (!name) {
828 res = -1;
829 goto cleanup;
830 }
831 22 res = PyObject_SetAttr(self, name, PyTuple_GET_ITEM(args, i));
832 22 Py_DECREF(name);
833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if (res < 0) {
834 goto cleanup;
835 }
836 }
837
2/2
✓ Branch 0 taken 8396 times.
✓ Branch 1 taken 5540 times.
13936 if (kw) {
838 5540 i = 0; /* needed by PyDict_Next */
839
2/2
✓ Branch 1 taken 8492 times.
✓ Branch 2 taken 5540 times.
14032 while (PyDict_Next(kw, &i, &key, &value)) {
840 8492 int contains = PySequence_Contains(fields, key);
841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8492 times.
8492 if (contains == -1) {
842 res = -1;
843 goto cleanup;
844
2/2
✓ Branch 0 taken 7370 times.
✓ Branch 1 taken 1122 times.
8492 } else if (contains == 1) {
845 7370 Py_ssize_t p = PySequence_Index(fields, key);
846
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7370 times.
7370 if (p == -1) {
847 res = -1;
848 goto cleanup;
849 }
850
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 7370 times.
7370 if (p < PyTuple_GET_SIZE(args)) {
851 PyErr_Format(PyExc_TypeError,
852 "%.400s got multiple values for argument '%U'",
853 Py_TYPE(self)->tp_name, key);
854 res = -1;
855 goto cleanup;
856 }
857 }
858 8492 res = PyObject_SetAttr(self, key, value);
859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8492 times.
8492 if (res < 0) {
860 goto cleanup;
861 }
862 }
863 }
864 13936 cleanup:
865 13936 Py_XDECREF(fields);
866 13936 return res;
867 }
868
869 /* Pickling support */
870 static PyObject *
871 ast_type_reduce(PyObject *self, PyObject *unused)
872 {
873 struct ast_state *state = get_ast_state();
874 if (state == NULL) {
875 return NULL;
876 }
877
878 PyObject *dict;
879 if (_PyObject_LookupAttr(self, state->__dict__, &dict) < 0) {
880 return NULL;
881 }
882 if (dict) {
883 return Py_BuildValue("O()N", Py_TYPE(self), dict);
884 }
885 return Py_BuildValue("O()", Py_TYPE(self));
886 }
887
888 static PyMemberDef ast_type_members[] = {
889 {"__dictoffset__", T_PYSSIZET, offsetof(AST_object, dict), READONLY},
890 {NULL} /* Sentinel */
891 };
892
893 static PyMethodDef ast_type_methods[] = {
894 {"__reduce__", ast_type_reduce, METH_NOARGS, NULL},
895 {NULL}
896 };
897
898 static PyGetSetDef ast_type_getsets[] = {
899 {"__dict__", PyObject_GenericGetDict, PyObject_GenericSetDict},
900 {NULL}
901 };
902
903 static PyType_Slot AST_type_slots[] = {
904 {Py_tp_dealloc, ast_dealloc},
905 {Py_tp_getattro, PyObject_GenericGetAttr},
906 {Py_tp_setattro, PyObject_GenericSetAttr},
907 {Py_tp_traverse, ast_traverse},
908 {Py_tp_clear, ast_clear},
909 {Py_tp_members, ast_type_members},
910 {Py_tp_methods, ast_type_methods},
911 {Py_tp_getset, ast_type_getsets},
912 {Py_tp_init, ast_type_init},
913 {Py_tp_alloc, PyType_GenericAlloc},
914 {Py_tp_new, PyType_GenericNew},
915 {Py_tp_free, PyObject_GC_Del},
916 {0, 0},
917 };
918
919 static PyType_Spec AST_type_spec = {
920 "ast.AST",
921 sizeof(AST_object),
922 0,
923 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC,
924 AST_type_slots
925 };
926
927 static PyObject *
928 93810 make_type(struct ast_state *state, const char *type, PyObject* base,
929 const char* const* fields, int num_fields, const char *doc)
930 {
931 PyObject *fnames, *result;
932 int i;
933 93810 fnames = PyTuple_New(num_fields);
934
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93810 times.
93810 if (!fnames) return NULL;
935
2/2
✓ Branch 0 taken 141510 times.
✓ Branch 1 taken 93810 times.
235320 for (i = 0; i < num_fields; i++) {
936 141510 PyObject *field = PyUnicode_InternFromString(fields[i]);
937
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 141510 times.
141510 if (!field) {
938 Py_DECREF(fnames);
939 return NULL;
940 }
941 141510 PyTuple_SET_ITEM(fnames, i, field);
942 }
943 93810 result = PyObject_CallFunction((PyObject*)&PyType_Type, "s(O){OOOOOOOs}",
944 type, base,
945 state->_fields, fnames,
946 state->__match_args__, fnames,
947 state->__module__,
948 state->ast,
949 state->__doc__, doc);
950 93810 Py_DECREF(fnames);
951 93810 return result;
952 }
953
954 static int
955 14310 add_attributes(struct ast_state *state, PyObject *type, const char * const *attrs, int num_fields)
956 {
957 int i, result;
958 14310 PyObject *s, *l = PyTuple_New(num_fields);
959
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14310 times.
14310 if (!l)
960 return 0;
961
2/2
✓ Branch 0 taken 22260 times.
✓ Branch 1 taken 14310 times.
36570 for (i = 0; i < num_fields; i++) {
962 22260 s = PyUnicode_InternFromString(attrs[i]);
963
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22260 times.
22260 if (!s) {
964 Py_DECREF(l);
965 return 0;
966 }
967 22260 PyTuple_SET_ITEM(l, i, s);
968 }
969 14310 result = PyObject_SetAttr(type, state->_attributes, l) >= 0;
970 14310 Py_DECREF(l);
971 14310 return result;
972 }
973
974 /* Conversion AST -> Python */
975
976 17261 static PyObject* ast2obj_list(struct ast_state *state, asdl_seq *seq, PyObject* (*func)(struct ast_state *state, void*))
977 {
978
2/2
✓ Branch 0 taken 10093 times.
✓ Branch 1 taken 7168 times.
17261 Py_ssize_t i, n = asdl_seq_LEN(seq);
979 17261 PyObject *result = PyList_New(n);
980 PyObject *value;
981
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17261 times.
17261 if (!result)
982 return NULL;
983
2/2
✓ Branch 0 taken 455558 times.
✓ Branch 1 taken 17261 times.
472819 for (i = 0; i < n; i++) {
984 455558 value = func(state, asdl_seq_GET_UNTYPED(seq, i));
985
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 455558 times.
455558 if (!value) {
986 Py_DECREF(result);
987 return NULL;
988 }
989 455558 PyList_SET_ITEM(result, i, value);
990 }
991 17261 return result;
992 }
993
994 906380 static PyObject* ast2obj_object(struct ast_state *Py_UNUSED(state), void *o)
995 {
996
2/2
✓ Branch 0 taken 448786 times.
✓ Branch 1 taken 457594 times.
906380 if (!o)
997 448786 o = Py_None;
998 906380 Py_INCREF((PyObject*)o);
999 906380 return (PyObject*)o;
1000 }
1001 #define ast2obj_constant ast2obj_object
1002 #define ast2obj_identifier ast2obj_object
1003 #define ast2obj_string ast2obj_object
1004
1005 1862788 static PyObject* ast2obj_int(struct ast_state *Py_UNUSED(state), long b)
1006 {
1007 1862788 return PyLong_FromLong(b);
1008 }
1009
1010 /* Conversion Python -> AST */
1011
1012 static int obj2ast_object(struct ast_state *Py_UNUSED(state), PyObject* obj, PyObject** out, PyArena* arena)
1013 {
1014 if (obj == Py_None)
1015 obj = NULL;
1016 if (obj) {
1017 if (_PyArena_AddPyObject(arena, obj) < 0) {
1018 *out = NULL;
1019 return -1;
1020 }
1021 Py_INCREF(obj);
1022 }
1023 *out = obj;
1024 return 0;
1025 }
1026
1027 static int obj2ast_constant(struct ast_state *Py_UNUSED(state), PyObject* obj, PyObject** out, PyArena* arena)
1028 {
1029 if (_PyArena_AddPyObject(arena, obj) < 0) {
1030 *out = NULL;
1031 return -1;
1032 }
1033 Py_INCREF(obj);
1034 *out = obj;
1035 return 0;
1036 }
1037
1038 static int obj2ast_identifier(struct ast_state *state, PyObject* obj, PyObject** out, PyArena* arena)
1039 {
1040 if (!PyUnicode_CheckExact(obj) && obj != Py_None) {
1041 PyErr_SetString(PyExc_TypeError, "AST identifier must be of type str");
1042 return 1;
1043 }
1044 return obj2ast_object(state, obj, out, arena);
1045 }
1046
1047 static int obj2ast_string(struct ast_state *state, PyObject* obj, PyObject** out, PyArena* arena)
1048 {
1049 if (!PyUnicode_CheckExact(obj) && !PyBytes_CheckExact(obj)) {
1050 PyErr_SetString(PyExc_TypeError, "AST string must be of type str");
1051 return 1;
1052 }
1053 return obj2ast_object(state, obj, out, arena);
1054 }
1055
1056 static int obj2ast_int(struct ast_state* Py_UNUSED(state), PyObject* obj, int* out, PyArena* arena)
1057 {
1058 int i;
1059 if (!PyLong_Check(obj)) {
1060 PyErr_Format(PyExc_ValueError, "invalid integer value: %R", obj);
1061 return 1;
1062 }
1063
1064 i = _PyLong_AsInt(obj);
1065 if (i == -1 && PyErr_Occurred())
1066 return 1;
1067 *out = i;
1068 return 0;
1069 }
1070
1071 795 static int add_ast_fields(struct ast_state *state)
1072 {
1073 PyObject *empty_tuple;
1074 795 empty_tuple = PyTuple_New(0);
1075
2/4
✓ Branch 0 taken 795 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
✗ Branch 3 not taken.
1590 if (!empty_tuple ||
1076
1/2
✓ Branch 1 taken 795 times.
✗ Branch 2 not taken.
1590 PyObject_SetAttrString(state->AST_type, "_fields", empty_tuple) < 0 ||
1077
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
1590 PyObject_SetAttrString(state->AST_type, "__match_args__", empty_tuple) < 0 ||
1078 795 PyObject_SetAttrString(state->AST_type, "_attributes", empty_tuple) < 0) {
1079 Py_XDECREF(empty_tuple);
1080 return -1;
1081 }
1082 795 Py_DECREF(empty_tuple);
1083 795 return 0;
1084 }
1085
1086
1087
1088 static int
1089 47664 init_types(struct ast_state *state)
1090 {
1091 // init_types() must not be called after _PyAST_Fini()
1092 // has been called
1093 assert(state->initialized >= 0);
1094
1095
2/2
✓ Branch 0 taken 46869 times.
✓ Branch 1 taken 795 times.
47664 if (state->initialized) {
1096 46869 return 1;
1097 }
1098
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (init_identifiers(state) < 0) {
1099 return 0;
1100 }
1101 795 state->AST_type = PyType_FromSpec(&AST_type_spec);
1102
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->AST_type) {
1103 return 0;
1104 }
1105
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (add_ast_fields(state) < 0) {
1106 return 0;
1107 }
1108 795 state->mod_type = make_type(state, "mod", state->AST_type, NULL, 0,
1109 "mod = Module(stmt* body, type_ignore* type_ignores)\n"
1110 " | Interactive(stmt* body)\n"
1111 " | Expression(expr body)\n"
1112 " | FunctionType(expr* argtypes, expr returns)");
1113
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->mod_type) return 0;
1114
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (!add_attributes(state, state->mod_type, NULL, 0)) return 0;
1115 795 state->Module_type = make_type(state, "Module", state->mod_type,
1116 Module_fields, 2,
1117 "Module(stmt* body, type_ignore* type_ignores)");
1118
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Module_type) return 0;
1119 795 state->Interactive_type = make_type(state, "Interactive", state->mod_type,
1120 Interactive_fields, 1,
1121 "Interactive(stmt* body)");
1122
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Interactive_type) return 0;
1123 795 state->Expression_type = make_type(state, "Expression", state->mod_type,
1124 Expression_fields, 1,
1125 "Expression(expr body)");
1126
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Expression_type) return 0;
1127 795 state->FunctionType_type = make_type(state, "FunctionType",
1128 state->mod_type, FunctionType_fields,
1129 2,
1130 "FunctionType(expr* argtypes, expr returns)");
1131
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->FunctionType_type) return 0;
1132 795 state->stmt_type = make_type(state, "stmt", state->AST_type, NULL, 0,
1133 "stmt = FunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment)\n"
1134 " | AsyncFunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment)\n"
1135 " | ClassDef(identifier name, expr* bases, keyword* keywords, stmt* body, expr* decorator_list)\n"
1136 " | Return(expr? value)\n"
1137 " | Delete(expr* targets)\n"
1138 " | Assign(expr* targets, expr value, string? type_comment)\n"
1139 " | AugAssign(expr target, operator op, expr value)\n"
1140 " | AnnAssign(expr target, expr annotation, expr? value, int simple)\n"
1141 " | For(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment)\n"
1142 " | AsyncFor(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment)\n"
1143 " | While(expr test, stmt* body, stmt* orelse)\n"
1144 " | If(expr test, stmt* body, stmt* orelse)\n"
1145 " | With(withitem* items, stmt* body, string? type_comment)\n"
1146 " | AsyncWith(withitem* items, stmt* body, string? type_comment)\n"
1147 " | Match(expr subject, match_case* cases)\n"
1148 " | Raise(expr? exc, expr? cause)\n"
1149 " | Try(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)\n"
1150 " | TryStar(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)\n"
1151 " | Assert(expr test, expr? msg)\n"
1152 " | Import(alias* names)\n"
1153 " | ImportFrom(identifier? module, alias* names, int? level)\n"
1154 " | Global(identifier* names)\n"
1155 " | Nonlocal(identifier* names)\n"
1156 " | Expr(expr value)\n"
1157 " | Pass\n"
1158 " | Break\n"
1159 " | Continue");
1160
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->stmt_type) return 0;
1161
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (!add_attributes(state, state->stmt_type, stmt_attributes, 4)) return 0;
1162
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (PyObject_SetAttr(state->stmt_type, state->end_lineno, Py_None) == -1)
1163 return 0;
1164
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (PyObject_SetAttr(state->stmt_type, state->end_col_offset, Py_None) ==
1165 -1)
1166 return 0;
1167 795 state->FunctionDef_type = make_type(state, "FunctionDef", state->stmt_type,
1168 FunctionDef_fields, 6,
1169 "FunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment)");
1170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->FunctionDef_type) return 0;
1171
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (PyObject_SetAttr(state->FunctionDef_type, state->returns, Py_None) ==
1172 -1)
1173 return 0;
1174
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (PyObject_SetAttr(state->FunctionDef_type, state->type_comment, Py_None)
1175 == -1)
1176 return 0;
1177 795 state->AsyncFunctionDef_type = make_type(state, "AsyncFunctionDef",
1178 state->stmt_type,
1179 AsyncFunctionDef_fields, 6,
1180 "AsyncFunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment)");
1181
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->AsyncFunctionDef_type) return 0;
1182
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (PyObject_SetAttr(state->AsyncFunctionDef_type, state->returns, Py_None)
1183 == -1)
1184 return 0;
1185
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (PyObject_SetAttr(state->AsyncFunctionDef_type, state->type_comment,
1186 Py_None) == -1)
1187 return 0;
1188 795 state->ClassDef_type = make_type(state, "ClassDef", state->stmt_type,
1189 ClassDef_fields, 5,
1190 "ClassDef(identifier name, expr* bases, keyword* keywords, stmt* body, expr* decorator_list)");
1191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->ClassDef_type) return 0;
1192 795 state->Return_type = make_type(state, "Return", state->stmt_type,
1193 Return_fields, 1,
1194 "Return(expr? value)");
1195
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Return_type) return 0;
1196
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (PyObject_SetAttr(state->Return_type, state->value, Py_None) == -1)
1197 return 0;
1198 795 state->Delete_type = make_type(state, "Delete", state->stmt_type,
1199 Delete_fields, 1,
1200 "Delete(expr* targets)");
1201
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Delete_type) return 0;
1202 795 state->Assign_type = make_type(state, "Assign", state->stmt_type,
1203 Assign_fields, 3,
1204 "Assign(expr* targets, expr value, string? type_comment)");
1205
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Assign_type) return 0;
1206
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (PyObject_SetAttr(state->Assign_type, state->type_comment, Py_None) ==
1207 -1)
1208 return 0;
1209 795 state->AugAssign_type = make_type(state, "AugAssign", state->stmt_type,
1210 AugAssign_fields, 3,
1211 "AugAssign(expr target, operator op, expr value)");
1212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->AugAssign_type) return 0;
1213 795 state->AnnAssign_type = make_type(state, "AnnAssign", state->stmt_type,
1214 AnnAssign_fields, 4,
1215 "AnnAssign(expr target, expr annotation, expr? value, int simple)");
1216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->AnnAssign_type) return 0;
1217
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (PyObject_SetAttr(state->AnnAssign_type, state->value, Py_None) == -1)
1218 return 0;
1219 795 state->For_type = make_type(state, "For", state->stmt_type, For_fields, 5,
1220 "For(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment)");
1221
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->For_type) return 0;
1222
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (PyObject_SetAttr(state->For_type, state->type_comment, Py_None) == -1)
1223 return 0;
1224 795 state->AsyncFor_type = make_type(state, "AsyncFor", state->stmt_type,
1225 AsyncFor_fields, 5,
1226 "AsyncFor(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment)");
1227
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->AsyncFor_type) return 0;
1228
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (PyObject_SetAttr(state->AsyncFor_type, state->type_comment, Py_None) ==
1229 -1)
1230 return 0;
1231 795 state->While_type = make_type(state, "While", state->stmt_type,
1232 While_fields, 3,
1233 "While(expr test, stmt* body, stmt* orelse)");
1234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->While_type) return 0;
1235 795 state->If_type = make_type(state, "If", state->stmt_type, If_fields, 3,
1236 "If(expr test, stmt* body, stmt* orelse)");
1237
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->If_type) return 0;
1238 795 state->With_type = make_type(state, "With", state->stmt_type, With_fields,
1239 3,
1240 "With(withitem* items, stmt* body, string? type_comment)");
1241
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->With_type) return 0;
1242
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (PyObject_SetAttr(state->With_type, state->type_comment, Py_None) == -1)
1243 return 0;
1244 795 state->AsyncWith_type = make_type(state, "AsyncWith", state->stmt_type,
1245 AsyncWith_fields, 3,
1246 "AsyncWith(withitem* items, stmt* body, string? type_comment)");
1247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->AsyncWith_type) return 0;
1248
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (PyObject_SetAttr(state->AsyncWith_type, state->type_comment, Py_None)
1249 == -1)
1250 return 0;
1251 795 state->Match_type = make_type(state, "Match", state->stmt_type,
1252 Match_fields, 2,
1253 "Match(expr subject, match_case* cases)");
1254
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Match_type) return 0;
1255 795 state->Raise_type = make_type(state, "Raise", state->stmt_type,
1256 Raise_fields, 2,
1257 "Raise(expr? exc, expr? cause)");
1258
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Raise_type) return 0;
1259
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (PyObject_SetAttr(state->Raise_type, state->exc, Py_None) == -1)
1260 return 0;
1261
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (PyObject_SetAttr(state->Raise_type, state->cause, Py_None) == -1)
1262 return 0;
1263 795 state->Try_type = make_type(state, "Try", state->stmt_type, Try_fields, 4,
1264 "Try(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)");
1265
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Try_type) return 0;
1266 795 state->TryStar_type = make_type(state, "TryStar", state->stmt_type,
1267 TryStar_fields, 4,
1268 "TryStar(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)");
1269
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->TryStar_type) return 0;
1270 795 state->Assert_type = make_type(state, "Assert", state->stmt_type,
1271 Assert_fields, 2,
1272 "Assert(expr test, expr? msg)");
1273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Assert_type) return 0;
1274
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (PyObject_SetAttr(state->Assert_type, state->msg, Py_None) == -1)
1275 return 0;
1276 795 state->Import_type = make_type(state, "Import", state->stmt_type,
1277 Import_fields, 1,
1278 "Import(alias* names)");
1279
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Import_type) return 0;
1280 795 state->ImportFrom_type = make_type(state, "ImportFrom", state->stmt_type,
1281 ImportFrom_fields, 3,
1282 "ImportFrom(identifier? module, alias* names, int? level)");
1283
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->ImportFrom_type) return 0;
1284
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (PyObject_SetAttr(state->ImportFrom_type, state->module, Py_None) == -1)
1285 return 0;
1286
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (PyObject_SetAttr(state->ImportFrom_type, state->level, Py_None) == -1)
1287 return 0;
1288 795 state->Global_type = make_type(state, "Global", state->stmt_type,
1289 Global_fields, 1,
1290 "Global(identifier* names)");
1291
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Global_type) return 0;
1292 795 state->Nonlocal_type = make_type(state, "Nonlocal", state->stmt_type,
1293 Nonlocal_fields, 1,
1294 "Nonlocal(identifier* names)");
1295
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Nonlocal_type) return 0;
1296 795 state->Expr_type = make_type(state, "Expr", state->stmt_type, Expr_fields,
1297 1,
1298 "Expr(expr value)");
1299
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Expr_type) return 0;
1300 795 state->Pass_type = make_type(state, "Pass", state->stmt_type, NULL, 0,
1301 "Pass");
1302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Pass_type) return 0;
1303 795 state->Break_type = make_type(state, "Break", state->stmt_type, NULL, 0,
1304 "Break");
1305
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Break_type) return 0;
1306 795 state->Continue_type = make_type(state, "Continue", state->stmt_type, NULL,
1307 0,
1308 "Continue");
1309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Continue_type) return 0;
1310 795 state->expr_type = make_type(state, "expr", state->AST_type, NULL, 0,
1311 "expr = BoolOp(boolop op, expr* values)\n"
1312 " | NamedExpr(expr target, expr value)\n"
1313 " | BinOp(expr left, operator op, expr right)\n"
1314 " | UnaryOp(unaryop op, expr operand)\n"
1315 " | Lambda(arguments args, expr body)\n"
1316 " | IfExp(expr test, expr body, expr orelse)\n"
1317 " | Dict(expr* keys, expr* values)\n"
1318 " | Set(expr* elts)\n"
1319 " | ListComp(expr elt, comprehension* generators)\n"
1320 " | SetComp(expr elt, comprehension* generators)\n"
1321 " | DictComp(expr key, expr value, comprehension* generators)\n"
1322 " | GeneratorExp(expr elt, comprehension* generators)\n"
1323 " | Await(expr value)\n"
1324 " | Yield(expr? value)\n"
1325 " | YieldFrom(expr value)\n"
1326 " | Compare(expr left, cmpop* ops, expr* comparators)\n"
1327 " | Call(expr func, expr* args, keyword* keywords)\n"
1328 " | FormattedValue(expr value, int conversion, expr? format_spec)\n"
1329 " | JoinedStr(expr* values)\n"
1330 " | Constant(constant value, string? kind)\n"
1331 " | Attribute(expr value, identifier attr, expr_context ctx)\n"
1332 " | Subscript(expr value, expr slice, expr_context ctx)\n"
1333 " | Starred(expr value, expr_context ctx)\n"
1334 " | Name(identifier id, expr_context ctx)\n"
1335 " | List(expr* elts, expr_context ctx)\n"
1336 " | Tuple(expr* elts, expr_context ctx)\n"
1337 " | Slice(expr? lower, expr? upper, expr? step)");
1338
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->expr_type) return 0;
1339
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (!add_attributes(state, state->expr_type, expr_attributes, 4)) return 0;
1340
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (PyObject_SetAttr(state->expr_type, state->end_lineno, Py_None) == -1)
1341 return 0;
1342
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (PyObject_SetAttr(state->expr_type, state->end_col_offset, Py_None) ==
1343 -1)
1344 return 0;
1345 795 state->BoolOp_type = make_type(state, "BoolOp", state->expr_type,
1346 BoolOp_fields, 2,
1347 "BoolOp(boolop op, expr* values)");
1348
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->BoolOp_type) return 0;
1349 795 state->NamedExpr_type = make_type(state, "NamedExpr", state->expr_type,
1350 NamedExpr_fields, 2,
1351 "NamedExpr(expr target, expr value)");
1352
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->NamedExpr_type) return 0;
1353 795 state->BinOp_type = make_type(state, "BinOp", state->expr_type,
1354 BinOp_fields, 3,
1355 "BinOp(expr left, operator op, expr right)");
1356
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->BinOp_type) return 0;
1357 795 state->UnaryOp_type = make_type(state, "UnaryOp", state->expr_type,
1358 UnaryOp_fields, 2,
1359 "UnaryOp(unaryop op, expr operand)");
1360
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->UnaryOp_type) return 0;
1361 795 state->Lambda_type = make_type(state, "Lambda", state->expr_type,
1362 Lambda_fields, 2,
1363 "Lambda(arguments args, expr body)");
1364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Lambda_type) return 0;
1365 795 state->IfExp_type = make_type(state, "IfExp", state->expr_type,
1366 IfExp_fields, 3,
1367 "IfExp(expr test, expr body, expr orelse)");
1368
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->IfExp_type) return 0;
1369 795 state->Dict_type = make_type(state, "Dict", state->expr_type, Dict_fields,
1370 2,
1371 "Dict(expr* keys, expr* values)");
1372
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Dict_type) return 0;
1373 795 state->Set_type = make_type(state, "Set", state->expr_type, Set_fields, 1,
1374 "Set(expr* elts)");
1375
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Set_type) return 0;
1376 795 state->ListComp_type = make_type(state, "ListComp", state->expr_type,
1377 ListComp_fields, 2,
1378 "ListComp(expr elt, comprehension* generators)");
1379
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->ListComp_type) return 0;
1380 795 state->SetComp_type = make_type(state, "SetComp", state->expr_type,
1381 SetComp_fields, 2,
1382 "SetComp(expr elt, comprehension* generators)");
1383
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->SetComp_type) return 0;
1384 795 state->DictComp_type = make_type(state, "DictComp", state->expr_type,
1385 DictComp_fields, 3,
1386 "DictComp(expr key, expr value, comprehension* generators)");
1387
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->DictComp_type) return 0;
1388 795 state->GeneratorExp_type = make_type(state, "GeneratorExp",
1389 state->expr_type, GeneratorExp_fields,
1390 2,
1391 "GeneratorExp(expr elt, comprehension* generators)");
1392
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->GeneratorExp_type) return 0;
1393 795 state->Await_type = make_type(state, "Await", state->expr_type,
1394 Await_fields, 1,
1395 "Await(expr value)");
1396
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Await_type) return 0;
1397 795 state->Yield_type = make_type(state, "Yield", state->expr_type,
1398 Yield_fields, 1,
1399 "Yield(expr? value)");
1400
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Yield_type) return 0;
1401
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (PyObject_SetAttr(state->Yield_type, state->value, Py_None) == -1)
1402 return 0;
1403 795 state->YieldFrom_type = make_type(state, "YieldFrom", state->expr_type,
1404 YieldFrom_fields, 1,
1405 "YieldFrom(expr value)");
1406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->YieldFrom_type) return 0;
1407 795 state->Compare_type = make_type(state, "Compare", state->expr_type,
1408 Compare_fields, 3,
1409 "Compare(expr left, cmpop* ops, expr* comparators)");
1410
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Compare_type) return 0;
1411 795 state->Call_type = make_type(state, "Call", state->expr_type, Call_fields,
1412 3,
1413 "Call(expr func, expr* args, keyword* keywords)");
1414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Call_type) return 0;
1415 795 state->FormattedValue_type = make_type(state, "FormattedValue",
1416 state->expr_type,
1417 FormattedValue_fields, 3,
1418 "FormattedValue(expr value, int conversion, expr? format_spec)");
1419
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->FormattedValue_type) return 0;
1420
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (PyObject_SetAttr(state->FormattedValue_type, state->format_spec,
1421 Py_None) == -1)
1422 return 0;
1423 795 state->JoinedStr_type = make_type(state, "JoinedStr", state->expr_type,
1424 JoinedStr_fields, 1,
1425 "JoinedStr(expr* values)");
1426
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->JoinedStr_type) return 0;
1427 795 state->Constant_type = make_type(state, "Constant", state->expr_type,
1428 Constant_fields, 2,
1429 "Constant(constant value, string? kind)");
1430
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Constant_type) return 0;
1431
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (PyObject_SetAttr(state->Constant_type, state->kind, Py_None) == -1)
1432 return 0;
1433 795 state->Attribute_type = make_type(state, "Attribute", state->expr_type,
1434 Attribute_fields, 3,
1435 "Attribute(expr value, identifier attr, expr_context ctx)");
1436
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Attribute_type) return 0;
1437 795 state->Subscript_type = make_type(state, "Subscript", state->expr_type,
1438 Subscript_fields, 3,
1439 "Subscript(expr value, expr slice, expr_context ctx)");
1440
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Subscript_type) return 0;
1441 795 state->Starred_type = make_type(state, "Starred", state->expr_type,
1442 Starred_fields, 2,
1443 "Starred(expr value, expr_context ctx)");
1444
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Starred_type) return 0;
1445 795 state->Name_type = make_type(state, "Name", state->expr_type, Name_fields,
1446 2,
1447 "Name(identifier id, expr_context ctx)");
1448
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Name_type) return 0;
1449 795 state->List_type = make_type(state, "List", state->expr_type, List_fields,
1450 2,
1451 "List(expr* elts, expr_context ctx)");
1452
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->List_type) return 0;
1453 795 state->Tuple_type = make_type(state, "Tuple", state->expr_type,
1454 Tuple_fields, 2,
1455 "Tuple(expr* elts, expr_context ctx)");
1456
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Tuple_type) return 0;
1457 795 state->Slice_type = make_type(state, "Slice", state->expr_type,
1458 Slice_fields, 3,
1459 "Slice(expr? lower, expr? upper, expr? step)");
1460
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Slice_type) return 0;
1461
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (PyObject_SetAttr(state->Slice_type, state->lower, Py_None) == -1)
1462 return 0;
1463
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (PyObject_SetAttr(state->Slice_type, state->upper, Py_None) == -1)
1464 return 0;
1465
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (PyObject_SetAttr(state->Slice_type, state->step, Py_None) == -1)
1466 return 0;
1467 795 state->expr_context_type = make_type(state, "expr_context",
1468 state->AST_type, NULL, 0,
1469 "expr_context = Load | Store | Del");
1470
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->expr_context_type) return 0;
1471
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (!add_attributes(state, state->expr_context_type, NULL, 0)) return 0;
1472 795 state->Load_type = make_type(state, "Load", state->expr_context_type, NULL,
1473 0,
1474 "Load");
1475
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Load_type) return 0;
1476 795 state->Load_singleton = PyType_GenericNew((PyTypeObject *)state->Load_type,
1477 NULL, NULL);
1478
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Load_singleton) return 0;
1479 795 state->Store_type = make_type(state, "Store", state->expr_context_type,
1480 NULL, 0,
1481 "Store");
1482
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Store_type) return 0;
1483 1590 state->Store_singleton = PyType_GenericNew((PyTypeObject
1484 795 *)state->Store_type, NULL, NULL);
1485
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Store_singleton) return 0;
1486 795 state->Del_type = make_type(state, "Del", state->expr_context_type, NULL, 0,
1487 "Del");
1488
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Del_type) return 0;
1489 795 state->Del_singleton = PyType_GenericNew((PyTypeObject *)state->Del_type,
1490 NULL, NULL);
1491
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Del_singleton) return 0;
1492 795 state->boolop_type = make_type(state, "boolop", state->AST_type, NULL, 0,
1493 "boolop = And | Or");
1494
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->boolop_type) return 0;
1495
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (!add_attributes(state, state->boolop_type, NULL, 0)) return 0;
1496 795 state->And_type = make_type(state, "And", state->boolop_type, NULL, 0,
1497 "And");
1498
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->And_type) return 0;
1499 795 state->And_singleton = PyType_GenericNew((PyTypeObject *)state->And_type,
1500 NULL, NULL);
1501
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->And_singleton) return 0;
1502 795 state->Or_type = make_type(state, "Or", state->boolop_type, NULL, 0,
1503 "Or");
1504
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Or_type) return 0;
1505 795 state->Or_singleton = PyType_GenericNew((PyTypeObject *)state->Or_type,
1506 NULL, NULL);
1507
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Or_singleton) return 0;
1508 795 state->operator_type = make_type(state, "operator", state->AST_type, NULL,
1509 0,
1510 "operator = Add | Sub | Mult | MatMult | Div | Mod | Pow | LShift | RShift | BitOr | BitXor | BitAnd | FloorDiv");
1511
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->operator_type) return 0;
1512
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (!add_attributes(state, state->operator_type, NULL, 0)) return 0;
1513 795 state->Add_type = make_type(state, "Add", state->operator_type, NULL, 0,
1514 "Add");
1515
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Add_type) return 0;
1516 795 state->Add_singleton = PyType_GenericNew((PyTypeObject *)state->Add_type,
1517 NULL, NULL);
1518
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Add_singleton) return 0;
1519 795 state->Sub_type = make_type(state, "Sub", state->operator_type, NULL, 0,
1520 "Sub");
1521
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Sub_type) return 0;
1522 795 state->Sub_singleton = PyType_GenericNew((PyTypeObject *)state->Sub_type,
1523 NULL, NULL);
1524
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Sub_singleton) return 0;
1525 795 state->Mult_type = make_type(state, "Mult", state->operator_type, NULL, 0,
1526 "Mult");
1527
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Mult_type) return 0;
1528 795 state->Mult_singleton = PyType_GenericNew((PyTypeObject *)state->Mult_type,
1529 NULL, NULL);
1530
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Mult_singleton) return 0;
1531 795 state->MatMult_type = make_type(state, "MatMult", state->operator_type,
1532 NULL, 0,
1533 "MatMult");
1534
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->MatMult_type) return 0;
1535 1590 state->MatMult_singleton = PyType_GenericNew((PyTypeObject
1536 795 *)state->MatMult_type, NULL,
1537 NULL);
1538
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->MatMult_singleton) return 0;
1539 795 state->Div_type = make_type(state, "Div", state->operator_type, NULL, 0,
1540 "Div");
1541
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Div_type) return 0;
1542 795 state->Div_singleton = PyType_GenericNew((PyTypeObject *)state->Div_type,
1543 NULL, NULL);
1544
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Div_singleton) return 0;
1545 795 state->Mod_type = make_type(state, "Mod", state->operator_type, NULL, 0,
1546 "Mod");
1547
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Mod_type) return 0;
1548 795 state->Mod_singleton = PyType_GenericNew((PyTypeObject *)state->Mod_type,
1549 NULL, NULL);
1550
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Mod_singleton) return 0;
1551 795 state->Pow_type = make_type(state, "Pow", state->operator_type, NULL, 0,
1552 "Pow");
1553
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Pow_type) return 0;
1554 795 state->Pow_singleton = PyType_GenericNew((PyTypeObject *)state->Pow_type,
1555 NULL, NULL);
1556
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Pow_singleton) return 0;
1557 795 state->LShift_type = make_type(state, "LShift", state->operator_type, NULL,
1558 0,
1559 "LShift");
1560
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->LShift_type) return 0;
1561 1590 state->LShift_singleton = PyType_GenericNew((PyTypeObject
1562 795 *)state->LShift_type, NULL,
1563 NULL);
1564
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->LShift_singleton) return 0;
1565 795 state->RShift_type = make_type(state, "RShift", state->operator_type, NULL,
1566 0,
1567 "RShift");
1568
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->RShift_type) return 0;
1569 1590 state->RShift_singleton = PyType_GenericNew((PyTypeObject
1570 795 *)state->RShift_type, NULL,
1571 NULL);
1572
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->RShift_singleton) return 0;
1573 795 state->BitOr_type = make_type(state, "BitOr", state->operator_type, NULL, 0,
1574 "BitOr");
1575
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->BitOr_type) return 0;
1576 1590 state->BitOr_singleton = PyType_GenericNew((PyTypeObject
1577 795 *)state->BitOr_type, NULL, NULL);
1578
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->BitOr_singleton) return 0;
1579 795 state->BitXor_type = make_type(state, "BitXor", state->operator_type, NULL,
1580 0,
1581 "BitXor");
1582
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->BitXor_type) return 0;
1583 1590 state->BitXor_singleton = PyType_GenericNew((PyTypeObject
1584 795 *)state->BitXor_type, NULL,
1585 NULL);
1586
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->BitXor_singleton) return 0;
1587 795 state->BitAnd_type = make_type(state, "BitAnd", state->operator_type, NULL,
1588 0,
1589 "BitAnd");
1590
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->BitAnd_type) return 0;
1591 1590 state->BitAnd_singleton = PyType_GenericNew((PyTypeObject
1592 795 *)state->BitAnd_type, NULL,
1593 NULL);
1594
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->BitAnd_singleton) return 0;
1595 795 state->FloorDiv_type = make_type(state, "FloorDiv", state->operator_type,
1596 NULL, 0,
1597 "FloorDiv");
1598
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->FloorDiv_type) return 0;
1599 1590 state->FloorDiv_singleton = PyType_GenericNew((PyTypeObject
1600 795 *)state->FloorDiv_type, NULL,
1601 NULL);
1602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->FloorDiv_singleton) return 0;
1603 795 state->unaryop_type = make_type(state, "unaryop", state->AST_type, NULL, 0,
1604 "unaryop = Invert | Not | UAdd | USub");
1605
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->unaryop_type) return 0;
1606
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (!add_attributes(state, state->unaryop_type, NULL, 0)) return 0;
1607 795 state->Invert_type = make_type(state, "Invert", state->unaryop_type, NULL,
1608 0,
1609 "Invert");
1610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Invert_type) return 0;
1611 1590 state->Invert_singleton = PyType_GenericNew((PyTypeObject
1612 795 *)state->Invert_type, NULL,
1613 NULL);
1614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Invert_singleton) return 0;
1615 795 state->Not_type = make_type(state, "Not", state->unaryop_type, NULL, 0,
1616 "Not");
1617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Not_type) return 0;
1618 795 state->Not_singleton = PyType_GenericNew((PyTypeObject *)state->Not_type,
1619 NULL, NULL);
1620
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Not_singleton) return 0;
1621 795 state->UAdd_type = make_type(state, "UAdd", state->unaryop_type, NULL, 0,
1622 "UAdd");
1623
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->UAdd_type) return 0;
1624 795 state->UAdd_singleton = PyType_GenericNew((PyTypeObject *)state->UAdd_type,
1625 NULL, NULL);
1626
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->UAdd_singleton) return 0;
1627 795 state->USub_type = make_type(state, "USub", state->unaryop_type, NULL, 0,
1628 "USub");
1629
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->USub_type) return 0;
1630 795 state->USub_singleton = PyType_GenericNew((PyTypeObject *)state->USub_type,
1631 NULL, NULL);
1632
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->USub_singleton) return 0;
1633 795 state->cmpop_type = make_type(state, "cmpop", state->AST_type, NULL, 0,
1634 "cmpop = Eq | NotEq | Lt | LtE | Gt | GtE | Is | IsNot | In | NotIn");
1635
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->cmpop_type) return 0;
1636
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (!add_attributes(state, state->cmpop_type, NULL, 0)) return 0;
1637 795 state->Eq_type = make_type(state, "Eq", state->cmpop_type, NULL, 0,
1638 "Eq");
1639
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Eq_type) return 0;
1640 795 state->Eq_singleton = PyType_GenericNew((PyTypeObject *)state->Eq_type,
1641 NULL, NULL);
1642
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Eq_singleton) return 0;
1643 795 state->NotEq_type = make_type(state, "NotEq", state->cmpop_type, NULL, 0,
1644 "NotEq");
1645
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->NotEq_type) return 0;
1646 1590 state->NotEq_singleton = PyType_GenericNew((PyTypeObject
1647 795 *)state->NotEq_type, NULL, NULL);
1648
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->NotEq_singleton) return 0;
1649 795 state->Lt_type = make_type(state, "Lt", state->cmpop_type, NULL, 0,
1650 "Lt");
1651
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Lt_type) return 0;
1652 795 state->Lt_singleton = PyType_GenericNew((PyTypeObject *)state->Lt_type,
1653 NULL, NULL);
1654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Lt_singleton) return 0;
1655 795 state->LtE_type = make_type(state, "LtE", state->cmpop_type, NULL, 0,
1656 "LtE");
1657
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->LtE_type) return 0;
1658 795 state->LtE_singleton = PyType_GenericNew((PyTypeObject *)state->LtE_type,
1659 NULL, NULL);
1660
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->LtE_singleton) return 0;
1661 795 state->Gt_type = make_type(state, "Gt", state->cmpop_type, NULL, 0,
1662 "Gt");
1663
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Gt_type) return 0;
1664 795 state->Gt_singleton = PyType_GenericNew((PyTypeObject *)state->Gt_type,
1665 NULL, NULL);
1666
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Gt_singleton) return 0;
1667 795 state->GtE_type = make_type(state, "GtE", state->cmpop_type, NULL, 0,
1668 "GtE");
1669
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->GtE_type) return 0;
1670 795 state->GtE_singleton = PyType_GenericNew((PyTypeObject *)state->GtE_type,
1671 NULL, NULL);
1672
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->GtE_singleton) return 0;
1673 795 state->Is_type = make_type(state, "Is", state->cmpop_type, NULL, 0,
1674 "Is");
1675
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Is_type) return 0;
1676 795 state->Is_singleton = PyType_GenericNew((PyTypeObject *)state->Is_type,
1677 NULL, NULL);
1678
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->Is_singleton) return 0;
1679 795 state->IsNot_type = make_type(state, "IsNot", state->cmpop_type, NULL, 0,
1680 "IsNot");
1681
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->IsNot_type) return 0;
1682 1590 state->IsNot_singleton = PyType_GenericNew((PyTypeObject
1683 795 *)state->IsNot_type, NULL, NULL);
1684
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->IsNot_singleton) return 0;
1685 795 state->In_type = make_type(state, "In", state->cmpop_type, NULL, 0,
1686 "In");
1687
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->In_type) return 0;
1688 795 state->In_singleton = PyType_GenericNew((PyTypeObject *)state->In_type,
1689 NULL, NULL);
1690
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->In_singleton) return 0;
1691 795 state->NotIn_type = make_type(state, "NotIn", state->cmpop_type, NULL, 0,
1692 "NotIn");
1693
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->NotIn_type) return 0;
1694 1590 state->NotIn_singleton = PyType_GenericNew((PyTypeObject
1695 795 *)state->NotIn_type, NULL, NULL);
1696
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->NotIn_singleton) return 0;
1697 795 state->comprehension_type = make_type(state, "comprehension",
1698 state->AST_type,
1699 comprehension_fields, 4,
1700 "comprehension(expr target, expr iter, expr* ifs, int is_async)");
1701
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->comprehension_type) return 0;
1702
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (!add_attributes(state, state->comprehension_type, NULL, 0)) return 0;
1703 795 state->excepthandler_type = make_type(state, "excepthandler",
1704 state->AST_type, NULL, 0,
1705 "excepthandler = ExceptHandler(expr? type, identifier? name, stmt* body)");
1706
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->excepthandler_type) return 0;
1707
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (!add_attributes(state, state->excepthandler_type,
1708 excepthandler_attributes, 4)) return 0;
1709
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (PyObject_SetAttr(state->excepthandler_type, state->end_lineno, Py_None)
1710 == -1)
1711 return 0;
1712
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (PyObject_SetAttr(state->excepthandler_type, state->end_col_offset,
1713 Py_None) == -1)
1714 return 0;
1715 795 state->ExceptHandler_type = make_type(state, "ExceptHandler",
1716 state->excepthandler_type,
1717 ExceptHandler_fields, 3,
1718 "ExceptHandler(expr? type, identifier? name, stmt* body)");
1719
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->ExceptHandler_type) return 0;
1720
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (PyObject_SetAttr(state->ExceptHandler_type, state->type, Py_None) == -1)
1721 return 0;
1722
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (PyObject_SetAttr(state->ExceptHandler_type, state->name, Py_None) == -1)
1723 return 0;
1724 795 state->arguments_type = make_type(state, "arguments", state->AST_type,
1725 arguments_fields, 7,
1726 "arguments(arg* posonlyargs, arg* args, arg? vararg, arg* kwonlyargs, expr* kw_defaults, arg? kwarg, expr* defaults)");
1727
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->arguments_type) return 0;
1728
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (!add_attributes(state, state->arguments_type, NULL, 0)) return 0;
1729
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (PyObject_SetAttr(state->arguments_type, state->vararg, Py_None) == -1)
1730 return 0;
1731
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (PyObject_SetAttr(state->arguments_type, state->kwarg, Py_None) == -1)
1732 return 0;
1733 795 state->arg_type = make_type(state, "arg", state->AST_type, arg_fields, 3,
1734 "arg(identifier arg, expr? annotation, string? type_comment)");
1735
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->arg_type) return 0;
1736
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (!add_attributes(state, state->arg_type, arg_attributes, 4)) return 0;
1737
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (PyObject_SetAttr(state->arg_type, state->annotation, Py_None) == -1)
1738 return 0;
1739
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (PyObject_SetAttr(state->arg_type, state->type_comment, Py_None) == -1)
1740 return 0;
1741
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (PyObject_SetAttr(state->arg_type, state->end_lineno, Py_None) == -1)
1742 return 0;
1743
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (PyObject_SetAttr(state->arg_type, state->end_col_offset, Py_None) == -1)
1744 return 0;
1745 795 state->keyword_type = make_type(state, "keyword", state->AST_type,
1746 keyword_fields, 2,
1747 "keyword(identifier? arg, expr value)");
1748
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->keyword_type) return 0;
1749
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (!add_attributes(state, state->keyword_type, keyword_attributes, 4))
1750 return 0;
1751
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (PyObject_SetAttr(state->keyword_type, state->arg, Py_None) == -1)
1752 return 0;
1753
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (PyObject_SetAttr(state->keyword_type, state->end_lineno, Py_None) == -1)
1754 return 0;
1755
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (PyObject_SetAttr(state->keyword_type, state->end_col_offset, Py_None)
1756 == -1)
1757 return 0;
1758 795 state->alias_type = make_type(state, "alias", state->AST_type,
1759 alias_fields, 2,
1760 "alias(identifier name, identifier? asname)");
1761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->alias_type) return 0;
1762
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (!add_attributes(state, state->alias_type, alias_attributes, 4)) return
1763 0;
1764
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (PyObject_SetAttr(state->alias_type, state->asname, Py_None) == -1)
1765 return 0;
1766
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (PyObject_SetAttr(state->alias_type, state->end_lineno, Py_None) == -1)
1767 return 0;
1768
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (PyObject_SetAttr(state->alias_type, state->end_col_offset, Py_None) ==
1769 -1)
1770 return 0;
1771 795 state->withitem_type = make_type(state, "withitem", state->AST_type,
1772 withitem_fields, 2,
1773 "withitem(expr context_expr, expr? optional_vars)");
1774
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->withitem_type) return 0;
1775
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (!add_attributes(state, state->withitem_type, NULL, 0)) return 0;
1776
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (PyObject_SetAttr(state->withitem_type, state->optional_vars, Py_None)
1777 == -1)
1778 return 0;
1779 795 state->match_case_type = make_type(state, "match_case", state->AST_type,
1780 match_case_fields, 3,
1781 "match_case(pattern pattern, expr? guard, stmt* body)");
1782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->match_case_type) return 0;
1783
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (!add_attributes(state, state->match_case_type, NULL, 0)) return 0;
1784
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (PyObject_SetAttr(state->match_case_type, state->guard, Py_None) == -1)
1785 return 0;
1786 795 state->pattern_type = make_type(state, "pattern", state->AST_type, NULL, 0,
1787 "pattern = MatchValue(expr value)\n"
1788 " | MatchSingleton(constant value)\n"
1789 " | MatchSequence(pattern* patterns)\n"
1790 " | MatchMapping(expr* keys, pattern* patterns, identifier? rest)\n"
1791 " | MatchClass(expr cls, pattern* patterns, identifier* kwd_attrs, pattern* kwd_patterns)\n"
1792 " | MatchStar(identifier? name)\n"
1793 " | MatchAs(pattern? pattern, identifier? name)\n"
1794 " | MatchOr(pattern* patterns)");
1795
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->pattern_type) return 0;
1796
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (!add_attributes(state, state->pattern_type, pattern_attributes, 4))
1797 return 0;
1798 795 state->MatchValue_type = make_type(state, "MatchValue",
1799 state->pattern_type, MatchValue_fields,
1800 1,
1801 "MatchValue(expr value)");
1802
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->MatchValue_type) return 0;
1803 795 state->MatchSingleton_type = make_type(state, "MatchSingleton",
1804 state->pattern_type,
1805 MatchSingleton_fields, 1,
1806 "MatchSingleton(constant value)");
1807
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->MatchSingleton_type) return 0;
1808 795 state->MatchSequence_type = make_type(state, "MatchSequence",
1809 state->pattern_type,
1810 MatchSequence_fields, 1,
1811 "MatchSequence(pattern* patterns)");
1812
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->MatchSequence_type) return 0;
1813 795 state->MatchMapping_type = make_type(state, "MatchMapping",
1814 state->pattern_type,
1815 MatchMapping_fields, 3,
1816 "MatchMapping(expr* keys, pattern* patterns, identifier? rest)");
1817
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->MatchMapping_type) return 0;
1818
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (PyObject_SetAttr(state->MatchMapping_type, state->rest, Py_None) == -1)
1819 return 0;
1820 795 state->MatchClass_type = make_type(state, "MatchClass",
1821 state->pattern_type, MatchClass_fields,
1822 4,
1823 "MatchClass(expr cls, pattern* patterns, identifier* kwd_attrs, pattern* kwd_patterns)");
1824
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->MatchClass_type) return 0;
1825 795 state->MatchStar_type = make_type(state, "MatchStar", state->pattern_type,
1826 MatchStar_fields, 1,
1827 "MatchStar(identifier? name)");
1828
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->MatchStar_type) return 0;
1829
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (PyObject_SetAttr(state->MatchStar_type, state->name, Py_None) == -1)
1830 return 0;
1831 795 state->MatchAs_type = make_type(state, "MatchAs", state->pattern_type,
1832 MatchAs_fields, 2,
1833 "MatchAs(pattern? pattern, identifier? name)");
1834
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->MatchAs_type) return 0;
1835
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (PyObject_SetAttr(state->MatchAs_type, state->pattern, Py_None) == -1)
1836 return 0;
1837
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (PyObject_SetAttr(state->MatchAs_type, state->name, Py_None) == -1)
1838 return 0;
1839 795 state->MatchOr_type = make_type(state, "MatchOr", state->pattern_type,
1840 MatchOr_fields, 1,
1841 "MatchOr(pattern* patterns)");
1842
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->MatchOr_type) return 0;
1843 795 state->type_ignore_type = make_type(state, "type_ignore", state->AST_type,
1844 NULL, 0,
1845 "type_ignore = TypeIgnore(int lineno, string tag)");
1846
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->type_ignore_type) return 0;
1847
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 795 times.
795 if (!add_attributes(state, state->type_ignore_type, NULL, 0)) return 0;
1848 795 state->TypeIgnore_type = make_type(state, "TypeIgnore",
1849 state->type_ignore_type,
1850 TypeIgnore_fields, 2,
1851 "TypeIgnore(int lineno, string tag)");
1852
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 795 times.
795 if (!state->TypeIgnore_type) return 0;
1853
1854 795 state->initialized = 1;
1855 795 return 1;
1856 }
1857
1858 static int obj2ast_mod(struct ast_state *state, PyObject* obj, mod_ty* out,
1859 PyArena* arena);
1860 static int obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out,
1861 PyArena* arena);
1862 static int obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out,
1863 PyArena* arena);
1864 static int obj2ast_expr_context(struct ast_state *state, PyObject* obj,
1865 expr_context_ty* out, PyArena* arena);
1866 static int obj2ast_boolop(struct ast_state *state, PyObject* obj, boolop_ty*
1867 out, PyArena* arena);
1868 static int obj2ast_operator(struct ast_state *state, PyObject* obj,
1869 operator_ty* out, PyArena* arena);
1870 static int obj2ast_unaryop(struct ast_state *state, PyObject* obj, unaryop_ty*
1871 out, PyArena* arena);
1872 static int obj2ast_cmpop(struct ast_state *state, PyObject* obj, cmpop_ty* out,
1873 PyArena* arena);
1874 static int obj2ast_comprehension(struct ast_state *state, PyObject* obj,
1875 comprehension_ty* out, PyArena* arena);
1876 static int obj2ast_excepthandler(struct ast_state *state, PyObject* obj,
1877 excepthandler_ty* out, PyArena* arena);
1878 static int obj2ast_arguments(struct ast_state *state, PyObject* obj,
1879 arguments_ty* out, PyArena* arena);
1880 static int obj2ast_arg(struct ast_state *state, PyObject* obj, arg_ty* out,
1881 PyArena* arena);
1882 static int obj2ast_keyword(struct ast_state *state, PyObject* obj, keyword_ty*
1883 out, PyArena* arena);
1884 static int obj2ast_alias(struct ast_state *state, PyObject* obj, alias_ty* out,
1885 PyArena* arena);
1886 static int obj2ast_withitem(struct ast_state *state, PyObject* obj,
1887 withitem_ty* out, PyArena* arena);
1888 static int obj2ast_match_case(struct ast_state *state, PyObject* obj,
1889 match_case_ty* out, PyArena* arena);
1890 static int obj2ast_pattern(struct ast_state *state, PyObject* obj, pattern_ty*
1891 out, PyArena* arena);
1892 static int obj2ast_type_ignore(struct ast_state *state, PyObject* obj,
1893 type_ignore_ty* out, PyArena* arena);
1894
1895 mod_ty
1896 43454 _PyAST_Module(asdl_stmt_seq * body, asdl_type_ignore_seq * type_ignores,
1897 PyArena *arena)
1898 {
1899 mod_ty p;
1900 43454 p = (mod_ty)_PyArena_Malloc(arena, sizeof(*p));
1901
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43454 times.
43454 if (!p)
1902 return NULL;
1903 43454 p->kind = Module_kind;
1904 43454 p->v.Module.body = body;
1905 43454 p->v.Module.type_ignores = type_ignores;
1906 43454 return p;
1907 }
1908
1909 mod_ty
1910 _PyAST_Interactive(asdl_stmt_seq * body, PyArena *arena)
1911 {
1912 mod_ty p;
1913 p = (mod_ty)_PyArena_Malloc(arena, sizeof(*p));
1914 if (!p)
1915 return NULL;
1916 p->kind = Interactive_kind;
1917 p->v.Interactive.body = body;
1918 return p;
1919 }
1920
1921 mod_ty
1922 116958 _PyAST_Expression(expr_ty body, PyArena *arena)
1923 {
1924 mod_ty p;
1925
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116958 times.
116958 if (!body) {
1926 PyErr_SetString(PyExc_ValueError,
1927 "field 'body' is required for Expression");
1928 return NULL;
1929 }
1930 116958 p = (mod_ty)_PyArena_Malloc(arena, sizeof(*p));
1931
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116958 times.
116958 if (!p)
1932 return NULL;
1933 116958 p->kind = Expression_kind;
1934 116958 p->v.Expression.body = body;
1935 116958 return p;
1936 }
1937
1938 mod_ty
1939 _PyAST_FunctionType(asdl_expr_seq * argtypes, expr_ty returns, PyArena *arena)
1940 {
1941 mod_ty p;
1942 if (!returns) {
1943 PyErr_SetString(PyExc_ValueError,
1944 "field 'returns' is required for FunctionType");
1945 return NULL;
1946 }
1947 p = (mod_ty)_PyArena_Malloc(arena, sizeof(*p));
1948 if (!p)
1949 return NULL;
1950 p->kind = FunctionType_kind;
1951 p->v.FunctionType.argtypes = argtypes;
1952 p->v.FunctionType.returns = returns;
1953 return p;
1954 }
1955
1956 stmt_ty
1957 173520 _PyAST_FunctionDef(identifier name, arguments_ty args, asdl_stmt_seq * body,
1958 asdl_expr_seq * decorator_list, expr_ty returns, string
1959 type_comment, int lineno, int col_offset, int end_lineno,
1960 int end_col_offset, PyArena *arena)
1961 {
1962 stmt_ty p;
1963
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 173520 times.
173520 if (!name) {
1964 PyErr_SetString(PyExc_ValueError,
1965 "field 'name' is required for FunctionDef");
1966 return NULL;
1967 }
1968
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 173520 times.
173520 if (!args) {
1969 PyErr_SetString(PyExc_ValueError,
1970 "field 'args' is required for FunctionDef");
1971 return NULL;
1972 }
1973 173520 p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
1974
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 173520 times.
173520 if (!p)
1975 return NULL;
1976 173520 p->kind = FunctionDef_kind;
1977 173520 p->v.FunctionDef.name = name;
1978 173520 p->v.FunctionDef.args = args;
1979 173520 p->v.FunctionDef.body = body;
1980 173520 p->v.FunctionDef.decorator_list = decorator_list;
1981 173520 p->v.FunctionDef.returns = returns;
1982 173520 p->v.FunctionDef.type_comment = type_comment;
1983 173520 p->lineno = lineno;
1984 173520 p->col_offset = col_offset;
1985 173520 p->end_lineno = end_lineno;
1986 173520 p->end_col_offset = end_col_offset;
1987 173520 return p;
1988 }
1989
1990 stmt_ty
1991 1133 _PyAST_AsyncFunctionDef(identifier name, arguments_ty args, asdl_stmt_seq *
1992 body, asdl_expr_seq * decorator_list, expr_ty returns,
1993 string type_comment, int lineno, int col_offset, int
1994 end_lineno, int end_col_offset, PyArena *arena)
1995 {
1996 stmt_ty p;
1997
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1133 times.
1133 if (!name) {
1998 PyErr_SetString(PyExc_ValueError,
1999 "field 'name' is required for AsyncFunctionDef");
2000 return NULL;
2001 }
2002
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1133 times.
1133 if (!args) {
2003 PyErr_SetString(PyExc_ValueError,
2004 "field 'args' is required for AsyncFunctionDef");
2005 return NULL;
2006 }
2007 1133 p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2008
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1133 times.
1133 if (!p)
2009 return NULL;
2010 1133 p->kind = AsyncFunctionDef_kind;
2011 1133 p->v.AsyncFunctionDef.name = name;
2012 1133 p->v.AsyncFunctionDef.args = args;
2013 1133 p->v.AsyncFunctionDef.body = body;
2014 1133 p->v.AsyncFunctionDef.decorator_list = decorator_list;
2015 1133 p->v.AsyncFunctionDef.returns = returns;
2016 1133 p->v.AsyncFunctionDef.type_comment = type_comment;
2017 1133 p->lineno = lineno;
2018 1133 p->col_offset = col_offset;
2019 1133 p->end_lineno = end_lineno;
2020 1133 p->end_col_offset = end_col_offset;
2021 1133 return p;
2022 }
2023
2024 stmt_ty
2025 15707 _PyAST_ClassDef(identifier name, asdl_expr_seq * bases, asdl_keyword_seq *
2026 keywords, asdl_stmt_seq * body, asdl_expr_seq * decorator_list,
2027 int lineno, int col_offset, int end_lineno, int end_col_offset,
2028 PyArena *arena)
2029 {
2030 stmt_ty p;
2031
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15707 times.
15707 if (!name) {
2032 PyErr_SetString(PyExc_ValueError,
2033 "field 'name' is required for ClassDef");
2034 return NULL;
2035 }
2036 15707 p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2037
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15707 times.
15707 if (!p)
2038 return NULL;
2039 15707 p->kind = ClassDef_kind;
2040 15707 p->v.ClassDef.name = name;
2041 15707 p->v.ClassDef.bases = bases;
2042 15707 p->v.ClassDef.keywords = keywords;
2043 15707 p->v.ClassDef.body = body;
2044 15707 p->v.ClassDef.decorator_list = decorator_list;
2045 15707 p->lineno = lineno;
2046 15707 p->col_offset = col_offset;
2047 15707 p->end_lineno = end_lineno;
2048 15707 p->end_col_offset = end_col_offset;
2049 15707 return p;
2050 }
2051
2052 stmt_ty
2053 150929 _PyAST_Return(expr_ty value, int lineno, int col_offset, int end_lineno, int
2054 end_col_offset, PyArena *arena)
2055 {
2056 stmt_ty p;
2057 150929 p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2058
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 150929 times.
150929 if (!p)
2059 return NULL;
2060 150929 p->kind = Return_kind;
2061 150929 p->v.Return.value = value;
2062 150929 p->lineno = lineno;
2063 150929 p->col_offset = col_offset;
2064 150929 p->end_lineno = end_lineno;
2065 150929 p->end_col_offset = end_col_offset;
2066 150929 return p;
2067 }
2068
2069 stmt_ty
2070 1643 _PyAST_Delete(asdl_expr_seq * targets, int lineno, int col_offset, int
2071 end_lineno, int end_col_offset, PyArena *arena)
2072 {
2073 stmt_ty p;
2074 1643 p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2075
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1643 times.
1643 if (!p)
2076 return NULL;
2077 1643 p->kind = Delete_kind;
2078 1643 p->v.Delete.targets = targets;
2079 1643 p->lineno = lineno;
2080 1643 p->col_offset = col_offset;
2081 1643 p->end_lineno = end_lineno;
2082 1643 p->end_col_offset = end_col_offset;
2083 1643 return p;
2084 }
2085
2086 stmt_ty
2087 421428 _PyAST_Assign(asdl_expr_seq * targets, expr_ty value, string type_comment, int
2088 lineno, int col_offset, int end_lineno, int end_col_offset,
2089 PyArena *arena)
2090 {
2091 stmt_ty p;
2092
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 421428 times.
421428 if (!value) {
2093 PyErr_SetString(PyExc_ValueError,
2094 "field 'value' is required for Assign");
2095 return NULL;
2096 }
2097 421428 p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 421428 times.
421428 if (!p)
2099 return NULL;
2100 421428 p->kind = Assign_kind;
2101 421428 p->v.Assign.targets = targets;
2102 421428 p->v.Assign.value = value;
2103 421428 p->v.Assign.type_comment = type_comment;
2104 421428 p->lineno = lineno;
2105 421428 p->col_offset = col_offset;
2106 421428 p->end_lineno = end_lineno;
2107 421428 p->end_col_offset = end_col_offset;
2108 421428 return p;
2109 }
2110
2111 stmt_ty
2112 15247 _PyAST_AugAssign(expr_ty target, operator_ty op, expr_ty value, int lineno, int
2113 col_offset, int end_lineno, int end_col_offset, PyArena *arena)
2114 {
2115 stmt_ty p;
2116
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15247 times.
15247 if (!target) {
2117 PyErr_SetString(PyExc_ValueError,
2118 "field 'target' is required for AugAssign");
2119 return NULL;
2120 }
2121
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15247 times.
15247 if (!op) {
2122 PyErr_SetString(PyExc_ValueError,
2123 "field 'op' is required for AugAssign");
2124 return NULL;
2125 }
2126
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15247 times.
15247 if (!value) {
2127 PyErr_SetString(PyExc_ValueError,
2128 "field 'value' is required for AugAssign");
2129 return NULL;
2130 }
2131 15247 p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2132
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15247 times.
15247 if (!p)
2133 return NULL;
2134 15247 p->kind = AugAssign_kind;
2135 15247 p->v.AugAssign.target = target;
2136 15247 p->v.AugAssign.op = op;
2137 15247 p->v.AugAssign.value = value;
2138 15247 p->lineno = lineno;
2139 15247 p->col_offset = col_offset;
2140 15247 p->end_lineno = end_lineno;
2141 15247 p->end_col_offset = end_col_offset;
2142 15247 return p;
2143 }
2144
2145 stmt_ty
2146 2553 _PyAST_AnnAssign(expr_ty target, expr_ty annotation, expr_ty value, int simple,
2147 int lineno, int col_offset, int end_lineno, int
2148 end_col_offset, PyArena *arena)
2149 {
2150 stmt_ty p;
2151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2553 times.
2553 if (!target) {
2152 PyErr_SetString(PyExc_ValueError,
2153 "field 'target' is required for AnnAssign");
2154 return NULL;
2155 }
2156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2553 times.
2553 if (!annotation) {
2157 PyErr_SetString(PyExc_ValueError,
2158 "field 'annotation' is required for AnnAssign");
2159 return NULL;
2160 }
2161 2553 p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2162
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2553 times.
2553 if (!p)
2163 return NULL;
2164 2553 p->kind = AnnAssign_kind;
2165 2553 p->v.AnnAssign.target = target;
2166 2553 p->v.AnnAssign.annotation = annotation;
2167 2553 p->v.AnnAssign.value = value;
2168 2553 p->v.AnnAssign.simple = simple;
2169 2553 p->lineno = lineno;
2170 2553 p->col_offset = col_offset;
2171 2553 p->end_lineno = end_lineno;
2172 2553 p->end_col_offset = end_col_offset;
2173 2553 return p;
2174 }
2175
2176 stmt_ty
2177 33992 _PyAST_For(expr_ty target, expr_ty iter, asdl_stmt_seq * body, asdl_stmt_seq *
2178 orelse, string type_comment, int lineno, int col_offset, int
2179 end_lineno, int end_col_offset, PyArena *arena)
2180 {
2181 stmt_ty p;
2182
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33992 times.
33992 if (!target) {
2183 PyErr_SetString(PyExc_ValueError,
2184 "field 'target' is required for For");
2185 return NULL;
2186 }
2187
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33992 times.
33992 if (!iter) {
2188 PyErr_SetString(PyExc_ValueError,
2189 "field 'iter' is required for For");
2190 return NULL;
2191 }
2192 33992 p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2193
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33992 times.
33992 if (!p)
2194 return NULL;
2195 33992 p->kind = For_kind;
2196 33992 p->v.For.target = target;
2197 33992 p->v.For.iter = iter;
2198 33992 p->v.For.body = body;
2199 33992 p->v.For.orelse = orelse;
2200 33992 p->v.For.type_comment = type_comment;
2201 33992 p->lineno = lineno;
2202 33992 p->col_offset = col_offset;
2203 33992 p->end_lineno = end_lineno;
2204 33992 p->end_col_offset = end_col_offset;
2205 33992 return p;
2206 }
2207
2208 stmt_ty
2209 3 _PyAST_AsyncFor(expr_ty target, expr_ty iter, asdl_stmt_seq * body,
2210 asdl_stmt_seq * orelse, string type_comment, int lineno, int
2211 col_offset, int end_lineno, int end_col_offset, PyArena *arena)
2212 {
2213 stmt_ty p;
2214
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (!target) {
2215 PyErr_SetString(PyExc_ValueError,
2216 "field 'target' is required for AsyncFor");
2217 return NULL;
2218 }
2219
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (!iter) {
2220 PyErr_SetString(PyExc_ValueError,
2221 "field 'iter' is required for AsyncFor");
2222 return NULL;
2223 }
2224 3 p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (!p)
2226 return NULL;
2227 3 p->kind = AsyncFor_kind;
2228 3 p->v.AsyncFor.target = target;
2229 3 p->v.AsyncFor.iter = iter;
2230 3 p->v.AsyncFor.body = body;
2231 3 p->v.AsyncFor.orelse = orelse;
2232 3 p->v.AsyncFor.type_comment = type_comment;
2233 3 p->lineno = lineno;
2234 3 p->col_offset = col_offset;
2235 3 p->end_lineno = end_lineno;
2236 3 p->end_col_offset = end_col_offset;
2237 3 return p;
2238 }
2239
2240 stmt_ty
2241 4097 _PyAST_While(expr_ty test, asdl_stmt_seq * body, asdl_stmt_seq * orelse, int
2242 lineno, int col_offset, int end_lineno, int end_col_offset,
2243 PyArena *arena)
2244 {
2245 stmt_ty p;
2246
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4097 times.
4097 if (!test) {
2247 PyErr_SetString(PyExc_ValueError,
2248 "field 'test' is required for While");
2249 return NULL;
2250 }
2251 4097 p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4097 times.
4097 if (!p)
2253 return NULL;
2254 4097 p->kind = While_kind;
2255 4097 p->v.While.test = test;
2256 4097 p->v.While.body = body;
2257 4097 p->v.While.orelse = orelse;
2258 4097 p->lineno = lineno;
2259 4097 p->col_offset = col_offset;
2260 4097 p->end_lineno = end_lineno;
2261 4097 p->end_col_offset = end_col_offset;
2262 4097 return p;
2263 }
2264
2265 stmt_ty
2266 137327 _PyAST_If(expr_ty test, asdl_stmt_seq * body, asdl_stmt_seq * orelse, int
2267 lineno, int col_offset, int end_lineno, int end_col_offset, PyArena
2268 *arena)
2269 {
2270 stmt_ty p;
2271
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137327 times.
137327 if (!test) {
2272 PyErr_SetString(PyExc_ValueError,
2273 "field 'test' is required for If");
2274 return NULL;
2275 }
2276 137327 p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2277
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137327 times.
137327 if (!p)
2278 return NULL;
2279 137327 p->kind = If_kind;
2280 137327 p->v.If.test = test;
2281 137327 p->v.If.body = body;
2282 137327 p->v.If.orelse = orelse;
2283 137327 p->lineno = lineno;
2284 137327 p->col_offset = col_offset;
2285 137327 p->end_lineno = end_lineno;
2286 137327 p->end_col_offset = end_col_offset;
2287 137327 return p;
2288 }
2289
2290 stmt_ty
2291 4321 _PyAST_With(asdl_withitem_seq * items, asdl_stmt_seq * body, string
2292 type_comment, int lineno, int col_offset, int end_lineno, int
2293 end_col_offset, PyArena *arena)
2294 {
2295 stmt_ty p;
2296 4321 p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2297
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4321 times.
4321 if (!p)
2298 return NULL;
2299 4321 p->kind = With_kind;
2300 4321 p->v.With.items = items;
2301 4321 p->v.With.body = body;
2302 4321 p->v.With.type_comment = type_comment;
2303 4321 p->lineno = lineno;
2304 4321 p->col_offset = col_offset;
2305 4321 p->end_lineno = end_lineno;
2306 4321 p->end_col_offset = end_col_offset;
2307 4321 return p;
2308 }
2309
2310 stmt_ty
2311 14 _PyAST_AsyncWith(asdl_withitem_seq * items, asdl_stmt_seq * body, string
2312 type_comment, int lineno, int col_offset, int end_lineno, int
2313 end_col_offset, PyArena *arena)
2314 {
2315 stmt_ty p;
2316 14 p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2317
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if (!p)
2318 return NULL;
2319 14 p->kind = AsyncWith_kind;
2320 14 p->v.AsyncWith.items = items;
2321 14 p->v.AsyncWith.body = body;
2322 14 p->v.AsyncWith.type_comment = type_comment;
2323 14 p->lineno = lineno;
2324 14 p->col_offset = col_offset;
2325 14 p->end_lineno = end_lineno;
2326 14 p->end_col_offset = end_col_offset;
2327 14 return p;
2328 }
2329
2330 stmt_ty
2331 3 _PyAST_Match(expr_ty subject, asdl_match_case_seq * cases, int lineno, int
2332 col_offset, int end_lineno, int end_col_offset, PyArena *arena)
2333 {
2334 stmt_ty p;
2335
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (!subject) {
2336 PyErr_SetString(PyExc_ValueError,
2337 "field 'subject' is required for Match");
2338 return NULL;
2339 }
2340 3 p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2341
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (!p)
2342 return NULL;
2343 3 p->kind = Match_kind;
2344 3 p->v.Match.subject = subject;
2345 3 p->v.Match.cases = cases;
2346 3 p->lineno = lineno;
2347 3 p->col_offset = col_offset;
2348 3 p->end_lineno = end_lineno;
2349 3 p->end_col_offset = end_col_offset;
2350 3 return p;
2351 }
2352
2353 stmt_ty
2354 20931 _PyAST_Raise(expr_ty exc, expr_ty cause, int lineno, int col_offset, int
2355 end_lineno, int end_col_offset, PyArena *arena)
2356 {
2357 stmt_ty p;
2358 20931 p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2359
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20931 times.
20931 if (!p)
2360 return NULL;
2361 20931 p->kind = Raise_kind;
2362 20931 p->v.Raise.exc = exc;
2363 20931 p->v.Raise.cause = cause;
2364 20931 p->lineno = lineno;
2365 20931 p->col_offset = col_offset;
2366 20931 p->end_lineno = end_lineno;
2367 20931 p->end_col_offset = end_col_offset;
2368 20931 return p;
2369 }
2370
2371 stmt_ty
2372 13085 _PyAST_Try(asdl_stmt_seq * body, asdl_excepthandler_seq * handlers,
2373 asdl_stmt_seq * orelse, asdl_stmt_seq * finalbody, int lineno, int
2374 col_offset, int end_lineno, int end_col_offset, PyArena *arena)
2375 {
2376 stmt_ty p;
2377 13085 p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2378
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13085 times.
13085 if (!p)
2379 return NULL;
2380 13085 p->kind = Try_kind;
2381 13085 p->v.Try.body = body;
2382 13085 p->v.Try.handlers = handlers;
2383 13085 p->v.Try.orelse = orelse;
2384 13085 p->v.Try.finalbody = finalbody;
2385 13085 p->lineno = lineno;
2386 13085 p->col_offset = col_offset;
2387 13085 p->end_lineno = end_lineno;
2388 13085 p->end_col_offset = end_col_offset;
2389 13085 return p;
2390 }
2391
2392 stmt_ty
2393 _PyAST_TryStar(asdl_stmt_seq * body, asdl_excepthandler_seq * handlers,
2394 asdl_stmt_seq * orelse, asdl_stmt_seq * finalbody, int lineno,
2395 int col_offset, int end_lineno, int end_col_offset, PyArena
2396 *arena)
2397 {
2398 stmt_ty p;
2399 p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2400 if (!p)
2401 return NULL;
2402 p->kind = TryStar_kind;
2403 p->v.TryStar.body = body;
2404 p->v.TryStar.handlers = handlers;
2405 p->v.TryStar.orelse = orelse;
2406 p->v.TryStar.finalbody = finalbody;
2407 p->lineno = lineno;
2408 p->col_offset = col_offset;
2409 p->end_lineno = end_lineno;
2410 p->end_col_offset = end_col_offset;
2411 return p;
2412 }
2413
2414 stmt_ty
2415 77851 _PyAST_Assert(expr_ty test, expr_ty msg, int lineno, int col_offset, int
2416 end_lineno, int end_col_offset, PyArena *arena)
2417 {
2418 stmt_ty p;
2419
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77851 times.
77851 if (!test) {
2420 PyErr_SetString(PyExc_ValueError,
2421 "field 'test' is required for Assert");
2422 return NULL;
2423 }
2424 77851 p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2425
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77851 times.
77851 if (!p)
2426 return NULL;
2427 77851 p->kind = Assert_kind;
2428 77851 p->v.Assert.test = test;
2429 77851 p->v.Assert.msg = msg;
2430 77851 p->lineno = lineno;
2431 77851 p->col_offset = col_offset;
2432 77851 p->end_lineno = end_lineno;
2433 77851 p->end_col_offset = end_col_offset;
2434 77851 return p;
2435 }
2436
2437 stmt_ty
2438 22151 _PyAST_Import(asdl_alias_seq * names, int lineno, int col_offset, int
2439 end_lineno, int end_col_offset, PyArena *arena)
2440 {
2441 stmt_ty p;
2442 22151 p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2443
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22151 times.
22151 if (!p)
2444 return NULL;
2445 22151 p->kind = Import_kind;
2446 22151 p->v.Import.names = names;
2447 22151 p->lineno = lineno;
2448 22151 p->col_offset = col_offset;
2449 22151 p->end_lineno = end_lineno;
2450 22151 p->end_col_offset = end_col_offset;
2451 22151 return p;
2452 }
2453
2454 stmt_ty
2455 33905 _PyAST_ImportFrom(identifier module, asdl_alias_seq * names, int level, int
2456 lineno, int col_offset, int end_lineno, int end_col_offset,
2457 PyArena *arena)
2458 {
2459 stmt_ty p;
2460 33905 p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2461
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33905 times.
33905 if (!p)
2462 return NULL;
2463 33905 p->kind = ImportFrom_kind;
2464 33905 p->v.ImportFrom.module = module;
2465 33905 p->v.ImportFrom.names = names;
2466 33905 p->v.ImportFrom.level = level;
2467 33905 p->lineno = lineno;
2468 33905 p->col_offset = col_offset;
2469 33905 p->end_lineno = end_lineno;
2470 33905 p->end_col_offset = end_col_offset;
2471 33905 return p;
2472 }
2473
2474 stmt_ty
2475 497 _PyAST_Global(asdl_identifier_seq * names, int lineno, int col_offset, int
2476 end_lineno, int end_col_offset, PyArena *arena)
2477 {
2478 stmt_ty p;
2479 497 p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2480
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 497 times.
497 if (!p)
2481 return NULL;
2482 497 p->kind = Global_kind;
2483 497 p->v.Global.names = names;
2484 497 p->lineno = lineno;
2485 497 p->col_offset = col_offset;
2486 497 p->end_lineno = end_lineno;
2487 497 p->end_col_offset = end_col_offset;
2488 497 return p;
2489 }
2490
2491 stmt_ty
2492 33 _PyAST_Nonlocal(asdl_identifier_seq * names, int lineno, int col_offset, int
2493 end_lineno, int end_col_offset, PyArena *arena)
2494 {
2495 stmt_ty p;
2496 33 p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2497
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if (!p)
2498 return NULL;
2499 33 p->kind = Nonlocal_kind;
2500 33 p->v.Nonlocal.names = names;
2501 33 p->lineno = lineno;
2502 33 p->col_offset = col_offset;
2503 33 p->end_lineno = end_lineno;
2504 33 p->end_col_offset = end_col_offset;
2505 33 return p;
2506 }
2507
2508 stmt_ty
2509 201338 _PyAST_Expr(expr_ty value, int lineno, int col_offset, int end_lineno, int
2510 end_col_offset, PyArena *arena)
2511 {
2512 stmt_ty p;
2513
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 201338 times.
201338 if (!value) {
2514 PyErr_SetString(PyExc_ValueError,
2515 "field 'value' is required for Expr");
2516 return NULL;
2517 }
2518 201338 p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2519
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 201338 times.
201338 if (!p)
2520 return NULL;
2521 201338 p->kind = Expr_kind;
2522 201338 p->v.Expr.value = value;
2523 201338 p->lineno = lineno;
2524 201338 p->col_offset = col_offset;
2525 201338 p->end_lineno = end_lineno;
2526 201338 p->end_col_offset = end_col_offset;
2527 201338 return p;
2528 }
2529
2530 stmt_ty
2531 5544 _PyAST_Pass(int lineno, int col_offset, int end_lineno, int end_col_offset,
2532 PyArena *arena)
2533 {
2534 stmt_ty p;
2535 5544 p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2536
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5544 times.
5544 if (!p)
2537 return NULL;
2538 5544 p->kind = Pass_kind;
2539 5544 p->lineno = lineno;
2540 5544 p->col_offset = col_offset;
2541 5544 p->end_lineno = end_lineno;
2542 5544 p->end_col_offset = end_col_offset;
2543 5544 return p;
2544 }
2545
2546 stmt_ty
2547 2762 _PyAST_Break(int lineno, int col_offset, int end_lineno, int end_col_offset,
2548 PyArena *arena)
2549 {
2550 stmt_ty p;
2551 2762 p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2552
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2762 times.
2762 if (!p)
2553 return NULL;
2554 2762 p->kind = Break_kind;
2555 2762 p->lineno = lineno;
2556 2762 p->col_offset = col_offset;
2557 2762 p->end_lineno = end_lineno;
2558 2762 p->end_col_offset = end_col_offset;
2559 2762 return p;
2560 }
2561
2562 stmt_ty
2563 2798 _PyAST_Continue(int lineno, int col_offset, int end_lineno, int end_col_offset,
2564 PyArena *arena)
2565 {
2566 stmt_ty p;
2567 2798 p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2568
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2798 times.
2798 if (!p)
2569 return NULL;
2570 2798 p->kind = Continue_kind;
2571 2798 p->lineno = lineno;
2572 2798 p->col_offset = col_offset;
2573 2798 p->end_lineno = end_lineno;
2574 2798 p->end_col_offset = end_col_offset;
2575 2798 return p;
2576 }
2577
2578 expr_ty
2579 32184 _PyAST_BoolOp(boolop_ty op, asdl_expr_seq * values, int lineno, int col_offset,
2580 int end_lineno, int end_col_offset, PyArena *arena)
2581 {
2582 expr_ty p;
2583
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32184 times.
32184 if (!op) {
2584 PyErr_SetString(PyExc_ValueError,
2585 "field 'op' is required for BoolOp");
2586 return NULL;
2587 }
2588 32184 p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
2589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32184 times.
32184 if (!p)
2590 return NULL;
2591 32184 p->kind = BoolOp_kind;
2592 32184 p->v.BoolOp.op = op;
2593 32184 p->v.BoolOp.values = values;
2594 32184 p->lineno = lineno;
2595 32184 p->col_offset = col_offset;
2596 32184 p->end_lineno = end_lineno;
2597 32184 p->end_col_offset = end_col_offset;
2598 32184 return p;
2599 }
2600
2601 expr_ty
2602 59 _PyAST_NamedExpr(expr_ty target, expr_ty value, int lineno, int col_offset, int
2603 end_lineno, int end_col_offset, PyArena *arena)
2604 {
2605 expr_ty p;
2606
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
59 if (!target) {
2607 PyErr_SetString(PyExc_ValueError,
2608 "field 'target' is required for NamedExpr");
2609 return NULL;
2610 }
2611
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
59 if (!value) {
2612 PyErr_SetString(PyExc_ValueError,
2613 "field 'value' is required for NamedExpr");
2614 return NULL;
2615 }
2616 59 p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
2617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
59 if (!p)
2618 return NULL;
2619 59 p->kind = NamedExpr_kind;
2620 59 p->v.NamedExpr.target = target;
2621 59 p->v.NamedExpr.value = value;
2622 59 p->lineno = lineno;
2623 59 p->col_offset = col_offset;
2624 59 p->end_lineno = end_lineno;
2625 59 p->end_col_offset = end_col_offset;
2626 59 return p;
2627 }
2628
2629 expr_ty
2630 1179149 _PyAST_BinOp(expr_ty left, operator_ty op, expr_ty right, int lineno, int
2631 col_offset, int end_lineno, int end_col_offset, PyArena *arena)
2632 {
2633 expr_ty p;
2634
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1179149 times.
1179149 if (!left) {
2635 PyErr_SetString(PyExc_ValueError,
2636 "field 'left' is required for BinOp");
2637 return NULL;
2638 }
2639
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1179149 times.
1179149 if (!op) {
2640 PyErr_SetString(PyExc_ValueError,
2641 "field 'op' is required for BinOp");
2642 return NULL;
2643 }
2644
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1179149 times.
1179149 if (!right) {
2645 PyErr_SetString(PyExc_ValueError,
2646 "field 'right' is required for BinOp");
2647 return NULL;
2648 }
2649 1179149 p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
2650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1179149 times.
1179149 if (!p)
2651 return NULL;
2652 1179149 p->kind = BinOp_kind;
2653 1179149 p->v.BinOp.left = left;
2654 1179149 p->v.BinOp.op = op;
2655 1179149 p->v.BinOp.right = right;
2656 1179149 p->lineno = lineno;
2657 1179149 p->col_offset = col_offset;
2658 1179149 p->end_lineno = end_lineno;
2659 1179149 p->end_col_offset = end_col_offset;
2660 1179149 return p;
2661 }
2662
2663 expr_ty
2664 102609 _PyAST_UnaryOp(unaryop_ty op, expr_ty operand, int lineno, int col_offset, int
2665 end_lineno, int end_col_offset, PyArena *arena)
2666 {
2667 expr_ty p;
2668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102609 times.
102609 if (!op) {
2669 PyErr_SetString(PyExc_ValueError,
2670 "field 'op' is required for UnaryOp");
2671 return NULL;
2672 }
2673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102609 times.
102609 if (!operand) {
2674 PyErr_SetString(PyExc_ValueError,
2675 "field 'operand' is required for UnaryOp");
2676 return NULL;
2677 }
2678 102609 p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
2679
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102609 times.
102609 if (!p)
2680 return NULL;
2681 102609 p->kind = UnaryOp_kind;
2682 102609 p->v.UnaryOp.op = op;
2683 102609 p->v.UnaryOp.operand = operand;
2684 102609 p->lineno = lineno;
2685 102609 p->col_offset = col_offset;
2686 102609 p->end_lineno = end_lineno;
2687 102609 p->end_col_offset = end_col_offset;
2688 102609 return p;
2689 }
2690
2691 expr_ty
2692 100164 _PyAST_Lambda(arguments_ty args, expr_ty body, int lineno, int col_offset, int
2693 end_lineno, int end_col_offset, PyArena *arena)
2694 {
2695 expr_ty p;
2696
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100164 times.
100164 if (!args) {
2697 PyErr_SetString(PyExc_ValueError,
2698 "field 'args' is required for Lambda");
2699 return NULL;
2700 }
2701
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100164 times.
100164 if (!body) {
2702 PyErr_SetString(PyExc_ValueError,
2703 "field 'body' is required for Lambda");
2704 return NULL;
2705 }
2706 100164 p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
2707
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100164 times.
100164 if (!p)
2708 return NULL;
2709 100164 p->kind = Lambda_kind;
2710 100164 p->v.Lambda.args = args;
2711 100164 p->v.Lambda.body = body;
2712 100164 p->lineno = lineno;
2713 100164 p->col_offset = col_offset;
2714 100164 p->end_lineno = end_lineno;
2715 100164 p->end_col_offset = end_col_offset;
2716 100164 return p;
2717 }
2718
2719 expr_ty
2720 6011 _PyAST_IfExp(expr_ty test, expr_ty body, expr_ty orelse, int lineno, int
2721 col_offset, int end_lineno, int end_col_offset, PyArena *arena)
2722 {
2723 expr_ty p;
2724
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6011 times.
6011 if (!test) {
2725 PyErr_SetString(PyExc_ValueError,
2726 "field 'test' is required for IfExp");
2727 return NULL;
2728 }
2729
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6011 times.
6011 if (!body) {
2730 PyErr_SetString(PyExc_ValueError,
2731 "field 'body' is required for IfExp");
2732 return NULL;
2733 }
2734
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6011 times.
6011 if (!orelse) {
2735 PyErr_SetString(PyExc_ValueError,
2736 "field 'orelse' is required for IfExp");
2737 return NULL;
2738 }
2739 6011 p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
2740
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6011 times.
6011 if (!p)
2741 return NULL;
2742 6011 p->kind = IfExp_kind;
2743 6011 p->v.IfExp.test = test;
2744 6011 p->v.IfExp.body = body;
2745 6011 p->v.IfExp.orelse = orelse;
2746 6011 p->lineno = lineno;
2747 6011 p->col_offset = col_offset;
2748 6011 p->end_lineno = end_lineno;
2749 6011 p->end_col_offset = end_col_offset;
2750 6011 return p;
2751 }
2752
2753 expr_ty
2754 45942 _PyAST_Dict(asdl_expr_seq * keys, asdl_expr_seq * values, int lineno, int
2755 col_offset, int end_lineno, int end_col_offset, PyArena *arena)
2756 {
2757 expr_ty p;
2758 45942 p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
2759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45942 times.
45942 if (!p)
2760 return NULL;
2761 45942 p->kind = Dict_kind;
2762 45942 p->v.Dict.keys = keys;
2763 45942 p->v.Dict.values = values;
2764 45942 p->lineno = lineno;
2765 45942 p->col_offset = col_offset;
2766 45942 p->end_lineno = end_lineno;
2767 45942 p->end_col_offset = end_col_offset;
2768 45942 return p;
2769 }
2770
2771 expr_ty
2772 3761 _PyAST_Set(asdl_expr_seq * elts, int lineno, int col_offset, int end_lineno,
2773 int end_col_offset, PyArena *arena)
2774 {
2775 expr_ty p;
2776 3761 p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
2777
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3761 times.
3761 if (!p)
2778 return NULL;
2779 3761 p->kind = Set_kind;
2780 3761 p->v.Set.elts = elts;
2781 3761 p->lineno = lineno;
2782 3761 p->col_offset = col_offset;
2783 3761 p->end_lineno = end_lineno;
2784 3761 p->end_col_offset = end_col_offset;
2785 3761 return p;
2786 }
2787
2788 expr_ty
2789 23557 _PyAST_ListComp(expr_ty elt, asdl_comprehension_seq * generators, int lineno,
2790 int col_offset, int end_lineno, int end_col_offset, PyArena
2791 *arena)
2792 {
2793 expr_ty p;
2794
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23557 times.
23557 if (!elt) {
2795 PyErr_SetString(PyExc_ValueError,
2796 "field 'elt' is required for ListComp");
2797 return NULL;
2798 }
2799 23557 p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
2800
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23557 times.
23557 if (!p)
2801 return NULL;
2802 23557 p->kind = ListComp_kind;
2803 23557 p->v.ListComp.elt = elt;
2804 23557 p->v.ListComp.generators = generators;
2805 23557 p->lineno = lineno;
2806 23557 p->col_offset = col_offset;
2807 23557 p->end_lineno = end_lineno;
2808 23557 p->end_col_offset = end_col_offset;
2809 23557 return p;
2810 }
2811
2812 expr_ty
2813 896 _PyAST_SetComp(expr_ty elt, asdl_comprehension_seq * generators, int lineno,
2814 int col_offset, int end_lineno, int end_col_offset, PyArena
2815 *arena)
2816 {
2817 expr_ty p;
2818
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 896 times.
896 if (!elt) {
2819 PyErr_SetString(PyExc_ValueError,
2820 "field 'elt' is required for SetComp");
2821 return NULL;
2822 }
2823 896 p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
2824
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 896 times.
896 if (!p)
2825 return NULL;
2826 896 p->kind = SetComp_kind;
2827 896 p->v.SetComp.elt = elt;
2828 896 p->v.SetComp.generators = generators;
2829 896 p->lineno = lineno;
2830 896 p->col_offset = col_offset;
2831 896 p->end_lineno = end_lineno;
2832 896 p->end_col_offset = end_col_offset;
2833 896 return p;
2834 }
2835
2836 expr_ty
2837 2172 _PyAST_DictComp(expr_ty key, expr_ty value, asdl_comprehension_seq *
2838 generators, int lineno, int col_offset, int end_lineno, int
2839 end_col_offset, PyArena *arena)
2840 {
2841 expr_ty p;
2842
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2172 times.
2172 if (!key) {
2843 PyErr_SetString(PyExc_ValueError,
2844 "field 'key' is required for DictComp");
2845 return NULL;
2846 }
2847
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2172 times.
2172 if (!value) {
2848 PyErr_SetString(PyExc_ValueError,
2849 "field 'value' is required for DictComp");
2850 return NULL;
2851 }
2852 2172 p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
2853
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2172 times.
2172 if (!p)
2854 return NULL;
2855 2172 p->kind = DictComp_kind;
2856 2172 p->v.DictComp.key = key;
2857 2172 p->v.DictComp.value = value;
2858 2172 p->v.DictComp.generators = generators;
2859 2172 p->lineno = lineno;
2860 2172 p->col_offset = col_offset;
2861 2172 p->end_lineno = end_lineno;
2862 2172 p->end_col_offset = end_col_offset;
2863 2172 return p;
2864 }
2865
2866 expr_ty
2867 8585 _PyAST_GeneratorExp(expr_ty elt, asdl_comprehension_seq * generators, int
2868 lineno, int col_offset, int end_lineno, int end_col_offset,
2869 PyArena *arena)
2870 {
2871 expr_ty p;
2872
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8585 times.
8585 if (!elt) {
2873 PyErr_SetString(PyExc_ValueError,
2874 "field 'elt' is required for GeneratorExp");
2875 return NULL;
2876 }
2877 8585 p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
2878
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8585 times.
8585 if (!p)
2879 return NULL;
2880 8585 p->kind = GeneratorExp_kind;
2881 8585 p->v.GeneratorExp.elt = elt;
2882 8585 p->v.GeneratorExp.generators = generators;
2883 8585 p->lineno = lineno;
2884 8585 p->col_offset = col_offset;
2885 8585 p->end_lineno = end_lineno;
2886 8585 p->end_col_offset = end_col_offset;
2887 8585 return p;
2888 }
2889
2890 expr_ty
2891 1062 _PyAST_Await(expr_ty value, int lineno, int col_offset, int end_lineno, int
2892 end_col_offset, PyArena *arena)
2893 {
2894 expr_ty p;
2895
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1062 times.
1062 if (!value) {
2896 PyErr_SetString(PyExc_ValueError,
2897 "field 'value' is required for Await");
2898 return NULL;
2899 }
2900 1062 p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
2901
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1062 times.
1062 if (!p)
2902 return NULL;
2903 1062 p->kind = Await_kind;
2904 1062 p->v.Await.value = value;
2905 1062 p->lineno = lineno;
2906 1062 p->col_offset = col_offset;
2907 1062 p->end_lineno = end_lineno;
2908 1062 p->end_col_offset = end_col_offset;
2909 1062 return p;
2910 }
2911
2912 expr_ty
2913 4742 _PyAST_Yield(expr_ty value, int lineno, int col_offset, int end_lineno, int
2914 end_col_offset, PyArena *arena)
2915 {
2916 expr_ty p;
2917 4742 p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
2918
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4742 times.
4742 if (!p)
2919 return NULL;
2920 4742 p->kind = Yield_kind;
2921 4742 p->v.Yield.value = value;
2922 4742 p->lineno = lineno;
2923 4742 p->col_offset = col_offset;
2924 4742 p->end_lineno = end_lineno;
2925 4742 p->end_col_offset = end_col_offset;
2926 4742 return p;
2927 }
2928
2929 expr_ty
2930 547 _PyAST_YieldFrom(expr_ty value, int lineno, int col_offset, int end_lineno, int
2931 end_col_offset, PyArena *arena)
2932 {
2933 expr_ty p;
2934
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 547 times.
547 if (!value) {
2935 PyErr_SetString(PyExc_ValueError,
2936 "field 'value' is required for YieldFrom");
2937 return NULL;
2938 }
2939 547 p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
2940
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 547 times.
547 if (!p)
2941 return NULL;
2942 547 p->kind = YieldFrom_kind;
2943 547 p->v.YieldFrom.value = value;
2944 547 p->lineno = lineno;
2945 547 p->col_offset = col_offset;
2946 547 p->end_lineno = end_lineno;
2947 547 p->end_col_offset = end_col_offset;
2948 547 return p;
2949 }
2950
2951 expr_ty
2952 169851 _PyAST_Compare(expr_ty left, asdl_int_seq * ops, asdl_expr_seq * comparators,
2953 int lineno, int col_offset, int end_lineno, int end_col_offset,
2954 PyArena *arena)
2955 {
2956 expr_ty p;
2957
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 169851 times.
169851 if (!left) {
2958 PyErr_SetString(PyExc_ValueError,
2959 "field 'left' is required for Compare");
2960 return NULL;
2961 }
2962 169851 p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
2963
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 169851 times.
169851 if (!p)
2964 return NULL;
2965 169851 p->kind = Compare_kind;
2966 169851 p->v.Compare.left = left;
2967 169851 p->v.Compare.ops = ops;
2968 169851 p->v.Compare.comparators = comparators;
2969 169851 p->lineno = lineno;
2970 169851 p->col_offset = col_offset;
2971 169851 p->end_lineno = end_lineno;
2972 169851 p->end_col_offset = end_col_offset;
2973 169851 return p;
2974 }
2975
2976 expr_ty
2977 2685200 _PyAST_Call(expr_ty func, asdl_expr_seq * args, asdl_keyword_seq * keywords,
2978 int lineno, int col_offset, int end_lineno, int end_col_offset,
2979 PyArena *arena)
2980 {
2981 expr_ty p;
2982
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2685200 times.
2685200 if (!func) {
2983 PyErr_SetString(PyExc_ValueError,
2984 "field 'func' is required for Call");
2985 return NULL;
2986 }
2987 2685200 p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
2988
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2685200 times.
2685200 if (!p)
2989 return NULL;
2990 2685200 p->kind = Call_kind;
2991 2685200 p->v.Call.func = func;
2992 2685200 p->v.Call.args = args;
2993 2685200 p->v.Call.keywords = keywords;
2994 2685200 p->lineno = lineno;
2995 2685200 p->col_offset = col_offset;
2996 2685200 p->end_lineno = end_lineno;
2997 2685200 p->end_col_offset = end_col_offset;
2998 2685200 return p;
2999 }
3000
3001 expr_ty
3002 34157 _PyAST_FormattedValue(expr_ty value, int conversion, expr_ty format_spec, int
3003 lineno, int col_offset, int end_lineno, int
3004 end_col_offset, PyArena *arena)
3005 {
3006 expr_ty p;
3007
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34157 times.
34157 if (!value) {
3008 PyErr_SetString(PyExc_ValueError,
3009 "field 'value' is required for FormattedValue");
3010 return NULL;
3011 }
3012 34157 p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
3013
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34157 times.
34157 if (!p)
3014 return NULL;
3015 34157 p->kind = FormattedValue_kind;
3016 34157 p->v.FormattedValue.value = value;
3017 34157 p->v.FormattedValue.conversion = conversion;
3018 34157 p->v.FormattedValue.format_spec = format_spec;
3019 34157 p->lineno = lineno;
3020 34157 p->col_offset = col_offset;
3021 34157 p->end_lineno = end_lineno;
3022 34157 p->end_col_offset = end_col_offset;
3023 34157 return p;
3024 }
3025
3026 expr_ty
3027 10989 _PyAST_JoinedStr(asdl_expr_seq * values, int lineno, int col_offset, int
3028 end_lineno, int end_col_offset, PyArena *arena)
3029 {
3030 expr_ty p;
3031 10989 p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
3032
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10989 times.
10989 if (!p)
3033 return NULL;
3034 10989 p->kind = JoinedStr_kind;
3035 10989 p->v.JoinedStr.values = values;
3036 10989 p->lineno = lineno;
3037 10989 p->col_offset = col_offset;
3038 10989 p->end_lineno = end_lineno;
3039 10989 p->end_col_offset = end_col_offset;
3040 10989 return p;
3041 }
3042
3043 expr_ty
3044 4130288 _PyAST_Constant(constant value, string kind, int lineno, int col_offset, int
3045 end_lineno, int end_col_offset, PyArena *arena)
3046 {
3047 expr_ty p;
3048
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4130288 times.
4130288 if (!value) {
3049 PyErr_SetString(PyExc_ValueError,
3050 "field 'value' is required for Constant");
3051 return NULL;
3052 }
3053 4130288 p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
3054
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4130288 times.
4130288 if (!p)
3055 return NULL;
3056 4130288 p->kind = Constant_kind;
3057 4130288 p->v.Constant.value = value;
3058 4130288 p->v.Constant.kind = kind;
3059 4130288 p->lineno = lineno;
3060 4130288 p->col_offset = col_offset;
3061 4130288 p->end_lineno = end_lineno;
3062 4130288 p->end_col_offset = end_col_offset;
3063 4130288 return p;
3064 }
3065
3066 expr_ty
3067 1114003 _PyAST_Attribute(expr_ty value, identifier attr, expr_context_ty ctx, int
3068 lineno, int col_offset, int end_lineno, int end_col_offset,
3069 PyArena *arena)
3070 {
3071 expr_ty p;
3072
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1114003 times.
1114003 if (!value) {
3073 PyErr_SetString(PyExc_ValueError,
3074 "field 'value' is required for Attribute");
3075 return NULL;
3076 }
3077
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1114003 times.
1114003 if (!attr) {
3078 PyErr_SetString(PyExc_ValueError,
3079 "field 'attr' is required for Attribute");
3080 return NULL;
3081 }
3082
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1114003 times.
1114003 if (!ctx) {
3083 PyErr_SetString(PyExc_ValueError,
3084 "field 'ctx' is required for Attribute");
3085 return NULL;
3086 }
3087 1114003 p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
3088
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1114003 times.
1114003 if (!p)
3089 return NULL;
3090 1114003 p->kind = Attribute_kind;
3091 1114003 p->v.Attribute.value = value;
3092 1114003 p->v.Attribute.attr = attr;
3093 1114003 p->v.Attribute.ctx = ctx;
3094 1114003 p->lineno = lineno;
3095 1114003 p->col_offset = col_offset;
3096 1114003 p->end_lineno = end_lineno;
3097 1114003 p->end_col_offset = end_col_offset;
3098 1114003 return p;
3099 }
3100
3101 expr_ty
3102 229269 _PyAST_Subscript(expr_ty value, expr_ty slice, expr_context_ty ctx, int lineno,
3103 int col_offset, int end_lineno, int end_col_offset, PyArena
3104 *arena)
3105 {
3106 expr_ty p;
3107
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 229269 times.
229269 if (!value) {
3108 PyErr_SetString(PyExc_ValueError,
3109 "field 'value' is required for Subscript");
3110 return NULL;
3111 }
3112
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 229269 times.
229269 if (!slice) {
3113 PyErr_SetString(PyExc_ValueError,
3114 "field 'slice' is required for Subscript");
3115 return NULL;
3116 }
3117
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 229269 times.
229269 if (!ctx) {
3118 PyErr_SetString(PyExc_ValueError,
3119 "field 'ctx' is required for Subscript");
3120 return NULL;
3121 }
3122 229269 p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
3123
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 229269 times.
229269 if (!p)
3124 return NULL;
3125 229269 p->kind = Subscript_kind;
3126 229269 p->v.Subscript.value = value;
3127 229269 p->v.Subscript.slice = slice;
3128 229269 p->v.Subscript.ctx = ctx;
3129 229269 p->lineno = lineno;
3130 229269 p->col_offset = col_offset;
3131 229269 p->end_lineno = end_lineno;
3132 229269 p->end_col_offset = end_col_offset;
3133 229269 return p;
3134 }
3135
3136 expr_ty
3137 11818 _PyAST_Starred(expr_ty value, expr_context_ty ctx, int lineno, int col_offset,
3138 int end_lineno, int end_col_offset, PyArena *arena)
3139 {
3140 expr_ty p;
3141
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11818 times.
11818 if (!value) {
3142 PyErr_SetString(PyExc_ValueError,
3143 "field 'value' is required for Starred");
3144 return NULL;
3145 }
3146
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11818 times.
11818 if (!ctx) {
3147 PyErr_SetString(PyExc_ValueError,
3148 "field 'ctx' is required for Starred");
3149 return NULL;
3150 }
3151 11818 p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
3152
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11818 times.
11818 if (!p)
3153 return NULL;
3154 11818 p->kind = Starred_kind;
3155 11818 p->v.Starred.value = value;
3156 11818 p->v.Starred.ctx = ctx;
3157 11818 p->lineno = lineno;
3158 11818 p->col_offset = col_offset;
3159 11818 p->end_lineno = end_lineno;
3160 11818 p->end_col_offset = end_col_offset;
3161 11818 return p;
3162 }
3163
3164 expr_ty
3165 25303841 _PyAST_Name(identifier id, expr_context_ty ctx, int lineno, int col_offset, int
3166 end_lineno, int end_col_offset, PyArena *arena)
3167 {
3168 expr_ty p;
3169
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25303841 times.
25303841 if (!id) {
3170 PyErr_SetString(PyExc_ValueError,
3171 "field 'id' is required for Name");
3172 return NULL;
3173 }
3174
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25303841 times.
25303841 if (!ctx) {
3175 PyErr_SetString(PyExc_ValueError,
3176 "field 'ctx' is required for Name");
3177 return NULL;
3178 }
3179 25303841 p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
3180
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25303841 times.
25303841 if (!p)
3181 return NULL;
3182 25303841 p->kind = Name_kind;
3183 25303841 p->v.Name.id = id;
3184 25303841 p->v.Name.ctx = ctx;
3185 25303841 p->lineno = lineno;
3186 25303841 p->col_offset = col_offset;
3187 25303841 p->end_lineno = end_lineno;
3188 25303841 p->end_col_offset = end_col_offset;
3189 25303841 return p;
3190 }
3191
3192 expr_ty
3193 155374 _PyAST_List(asdl_expr_seq * elts, expr_context_ty ctx, int lineno, int
3194 col_offset, int end_lineno, int end_col_offset, PyArena *arena)
3195 {
3196 expr_ty p;
3197
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 155374 times.
155374 if (!ctx) {
3198 PyErr_SetString(PyExc_ValueError,
3199 "field 'ctx' is required for List");
3200 return NULL;
3201 }
3202 155374 p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
3203
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 155374 times.
155374 if (!p)
3204 return NULL;
3205 155374 p->kind = List_kind;
3206 155374 p->v.List.elts = elts;
3207 155374 p->v.List.ctx = ctx;
3208 155374 p->lineno = lineno;
3209 155374 p->col_offset = col_offset;
3210 155374 p->end_lineno = end_lineno;
3211 155374 p->end_col_offset = end_col_offset;
3212 155374 return p;
3213 }
3214
3215 expr_ty
3216 467915 _PyAST_Tuple(asdl_expr_seq * elts, expr_context_ty ctx, int lineno, int
3217 col_offset, int end_lineno, int end_col_offset, PyArena *arena)
3218 {
3219 expr_ty p;
3220
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 467915 times.
467915 if (!ctx) {
3221 PyErr_SetString(PyExc_ValueError,
3222 "field 'ctx' is required for Tuple");
3223 return NULL;
3224 }
3225 467915 p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
3226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 467915 times.
467915 if (!p)
3227 return NULL;
3228 467915 p->kind = Tuple_kind;
3229 467915 p->v.Tuple.elts = elts;
3230 467915 p->v.Tuple.ctx = ctx;
3231 467915 p->lineno = lineno;
3232 467915 p->col_offset = col_offset;
3233 467915 p->end_lineno = end_lineno;
3234 467915 p->end_col_offset = end_col_offset;
3235 467915 return p;
3236 }
3237
3238 expr_ty
3239 22422 _PyAST_Slice(expr_ty lower, expr_ty upper, expr_ty step, int lineno, int
3240 col_offset, int end_lineno, int end_col_offset, PyArena *arena)
3241 {
3242 expr_ty p;
3243 22422 p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
3244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22422 times.
22422 if (!p)
3245 return NULL;
3246 22422 p->kind = Slice_kind;
3247 22422 p->v.Slice.lower = lower;
3248 22422 p->v.Slice.upper = upper;
3249 22422 p->v.Slice.step = step;
3250 22422 p->lineno = lineno;
3251 22422 p->col_offset = col_offset;
3252 22422 p->end_lineno = end_lineno;
3253 22422 p->end_col_offset = end_col_offset;
3254 22422 return p;
3255 }
3256
3257 comprehension_ty
3258 36315 _PyAST_comprehension(expr_ty target, expr_ty iter, asdl_expr_seq * ifs, int
3259 is_async, PyArena *arena)
3260 {
3261 comprehension_ty p;
3262
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36315 times.
36315 if (!target) {
3263 PyErr_SetString(PyExc_ValueError,
3264 "field 'target' is required for comprehension");
3265 return NULL;
3266 }
3267
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36315 times.
36315 if (!iter) {
3268 PyErr_SetString(PyExc_ValueError,
3269 "field 'iter' is required for comprehension");
3270 return NULL;
3271 }
3272 36315 p = (comprehension_ty)_PyArena_Malloc(arena, sizeof(*p));
3273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36315 times.
36315 if (!p)
3274 return NULL;
3275 36315 p->target = target;
3276 36315 p->iter = iter;
3277 36315 p->ifs = ifs;
3278 36315 p->is_async = is_async;
3279 36315 return p;
3280 }
3281
3282 excepthandler_ty
3283 11807 _PyAST_ExceptHandler(expr_ty type, identifier name, asdl_stmt_seq * body, int
3284 lineno, int col_offset, int end_lineno, int
3285 end_col_offset, PyArena *arena)
3286 {
3287 excepthandler_ty p;
3288 11807 p = (excepthandler_ty)_PyArena_Malloc(arena, sizeof(*p));
3289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11807 times.
11807 if (!p)
3290 return NULL;
3291 11807 p->kind = ExceptHandler_kind;
3292 11807 p->v.ExceptHandler.type = type;
3293 11807 p->v.ExceptHandler.name = name;
3294 11807 p->v.ExceptHandler.body = body;
3295 11807 p->lineno = lineno;
3296 11807 p->col_offset = col_offset;
3297 11807 p->end_lineno = end_lineno;
3298 11807 p->end_col_offset = end_col_offset;
3299 11807 return p;
3300 }
3301
3302 arguments_ty
3303 261246 _PyAST_arguments(asdl_arg_seq * posonlyargs, asdl_arg_seq * args, arg_ty
3304 vararg, asdl_arg_seq * kwonlyargs, asdl_expr_seq *
3305 kw_defaults, arg_ty kwarg, asdl_expr_seq * defaults, PyArena
3306 *arena)
3307 {
3308 arguments_ty p;
3309 261246 p = (arguments_ty)_PyArena_Malloc(arena, sizeof(*p));
3310
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 261246 times.
261246 if (!p)
3311 return NULL;
3312 261246 p->posonlyargs = posonlyargs;
3313 261246 p->args = args;
3314 261246 p->vararg = vararg;
3315 261246 p->kwonlyargs = kwonlyargs;
3316 261246 p->kw_defaults = kw_defaults;
3317 261246 p->kwarg = kwarg;
3318 261246 p->defaults = defaults;
3319 261246 return p;
3320 }
3321
3322 arg_ty
3323 5919440 _PyAST_arg(identifier arg, expr_ty annotation, string type_comment, int lineno,
3324 int col_offset, int end_lineno, int end_col_offset, PyArena *arena)
3325 {
3326 arg_ty p;
3327
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5919440 times.
5919440 if (!arg) {
3328 PyErr_SetString(PyExc_ValueError,
3329 "field 'arg' is required for arg");
3330 return NULL;
3331 }
3332 5919440 p = (arg_ty)_PyArena_Malloc(arena, sizeof(*p));
3333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5919440 times.
5919440 if (!p)
3334 return NULL;
3335 5919440 p->arg = arg;
3336 5919440 p->annotation = annotation;
3337 5919440 p->type_comment = type_comment;
3338 5919440 p->lineno = lineno;
3339 5919440 p->col_offset = col_offset;
3340 5919440 p->end_lineno = end_lineno;
3341 5919440 p->end_col_offset = end_col_offset;
3342 5919440 return p;
3343 }
3344
3345 keyword_ty
3346 218237 _PyAST_keyword(identifier arg, expr_ty value, int lineno, int col_offset, int
3347 end_lineno, int end_col_offset, PyArena *arena)
3348 {
3349 keyword_ty p;
3350
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 218237 times.
218237 if (!value) {
3351 PyErr_SetString(PyExc_ValueError,
3352 "field 'value' is required for keyword");
3353 return NULL;
3354 }
3355 218237 p = (keyword_ty)_PyArena_Malloc(arena, sizeof(*p));
3356
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 218237 times.
218237 if (!p)
3357 return NULL;
3358 218237 p->arg = arg;
3359 218237 p->value = value;
3360 218237 p->lineno = lineno;
3361 218237 p->col_offset = col_offset;
3362 218237 p->end_lineno = end_lineno;
3363 218237 p->end_col_offset = end_col_offset;
3364 218237 return p;
3365 }
3366
3367 alias_ty
3368 105747 _PyAST_alias(identifier name, identifier asname, int lineno, int col_offset,
3369 int end_lineno, int end_col_offset, PyArena *arena)
3370 {
3371 alias_ty p;
3372
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105747 times.
105747 if (!name) {
3373 PyErr_SetString(PyExc_ValueError,
3374 "field 'name' is required for alias");
3375 return NULL;
3376 }
3377 105747 p = (alias_ty)_PyArena_Malloc(arena, sizeof(*p));
3378
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105747 times.
105747 if (!p)
3379 return NULL;
3380 105747 p->name = name;
3381 105747 p->asname = asname;
3382 105747 p->lineno = lineno;
3383 105747 p->col_offset = col_offset;
3384 105747 p->end_lineno = end_lineno;
3385 105747 p->end_col_offset = end_col_offset;
3386 105747 return p;
3387 }
3388
3389 withitem_ty
3390 4354 _PyAST_withitem(expr_ty context_expr, expr_ty optional_vars, PyArena *arena)
3391 {
3392 withitem_ty p;
3393
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4354 times.
4354 if (!context_expr) {
3394 PyErr_SetString(PyExc_ValueError,
3395 "field 'context_expr' is required for withitem");
3396 return NULL;
3397 }
3398 4354 p = (withitem_ty)_PyArena_Malloc(arena, sizeof(*p));
3399
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4354 times.
4354 if (!p)
3400 return NULL;
3401 4354 p->context_expr = context_expr;
3402 4354 p->optional_vars = optional_vars;
3403 4354 return p;
3404 }
3405
3406 match_case_ty
3407 7 _PyAST_match_case(pattern_ty pattern, expr_ty guard, asdl_stmt_seq * body,
3408 PyArena *arena)
3409 {
3410 match_case_ty p;
3411
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if (!pattern) {
3412 PyErr_SetString(PyExc_ValueError,
3413 "field 'pattern' is required for match_case");
3414 return NULL;
3415 }
3416 7 p = (match_case_ty)_PyArena_Malloc(arena, sizeof(*p));
3417
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if (!p)
3418 return NULL;
3419 7 p->pattern = pattern;
3420 7 p->guard = guard;
3421 7 p->body = body;
3422 7 return p;
3423 }
3424
3425 pattern_ty
3426 _PyAST_MatchValue(expr_ty value, int lineno, int col_offset, int end_lineno,
3427 int end_col_offset, PyArena *arena)
3428 {
3429 pattern_ty p;
3430 if (!value) {
3431 PyErr_SetString(PyExc_ValueError,
3432 "field 'value' is required for MatchValue");
3433 return NULL;
3434 }
3435 p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
3436 if (!p)
3437 return NULL;
3438 p->kind = MatchValue_kind;
3439 p->v.MatchValue.value = value;
3440 p->lineno = lineno;
3441 p->col_offset = col_offset;
3442 p->end_lineno = end_lineno;
3443 p->end_col_offset = end_col_offset;
3444 return p;
3445 }
3446
3447 pattern_ty
3448 1 _PyAST_MatchSingleton(constant value, int lineno, int col_offset, int
3449 end_lineno, int end_col_offset, PyArena *arena)
3450 {
3451 pattern_ty p;
3452
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (!value) {
3453 PyErr_SetString(PyExc_ValueError,
3454 "field 'value' is required for MatchSingleton");
3455 return NULL;
3456 }
3457 1 p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
3458
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (!p)
3459 return NULL;
3460 1 p->kind = MatchSingleton_kind;
3461 1 p->v.MatchSingleton.value = value;
3462 1 p->lineno = lineno;
3463 1 p->col_offset = col_offset;
3464 1 p->end_lineno = end_lineno;
3465 1 p->end_col_offset = end_col_offset;
3466 1 return p;
3467 }
3468
3469 pattern_ty
3470 _PyAST_MatchSequence(asdl_pattern_seq * patterns, int lineno, int col_offset,
3471 int end_lineno, int end_col_offset, PyArena *arena)
3472 {
3473 pattern_ty p;
3474 p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
3475 if (!p)
3476 return NULL;
3477 p->kind = MatchSequence_kind;
3478 p->v.MatchSequence.patterns = patterns;
3479 p->lineno = lineno;
3480 p->col_offset = col_offset;
3481 p->end_lineno = end_lineno;
3482 p->end_col_offset = end_col_offset;
3483 return p;
3484 }
3485
3486 pattern_ty
3487 _PyAST_MatchMapping(asdl_expr_seq * keys, asdl_pattern_seq * patterns,
3488 identifier rest, int lineno, int col_offset, int
3489 end_lineno, int end_col_offset, PyArena *arena)
3490 {
3491 pattern_ty p;
3492 p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
3493 if (!p)
3494 return NULL;
3495 p->kind = MatchMapping_kind;
3496 p->v.MatchMapping.keys = keys;
3497 p->v.MatchMapping.patterns = patterns;
3498 p->v.MatchMapping.rest = rest;
3499 p->lineno = lineno;
3500 p->col_offset = col_offset;
3501 p->end_lineno = end_lineno;
3502 p->end_col_offset = end_col_offset;
3503 return p;
3504 }
3505
3506 pattern_ty
3507 4 _PyAST_MatchClass(expr_ty cls, asdl_pattern_seq * patterns, asdl_identifier_seq
3508 * kwd_attrs, asdl_pattern_seq * kwd_patterns, int lineno, int
3509 col_offset, int end_lineno, int end_col_offset, PyArena
3510 *arena)
3511 {
3512 pattern_ty p;
3513
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!cls) {
3514 PyErr_SetString(PyExc_ValueError,
3515 "field 'cls' is required for MatchClass");
3516 return NULL;
3517 }
3518 4 p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
3519
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!p)
3520 return NULL;
3521 4 p->kind = MatchClass_kind;
3522 4 p->v.MatchClass.cls = cls;
3523 4 p->v.MatchClass.patterns = patterns;
3524 4 p->v.MatchClass.kwd_attrs = kwd_attrs;
3525 4 p->v.MatchClass.kwd_patterns = kwd_patterns;
3526 4 p->lineno = lineno;
3527 4 p->col_offset = col_offset;
3528 4 p->end_lineno = end_lineno;
3529 4 p->end_col_offset = end_col_offset;
3530 4 return p;
3531 }
3532
3533 pattern_ty
3534 _PyAST_MatchStar(identifier name, int lineno, int col_offset, int end_lineno,
3535 int end_col_offset, PyArena *arena)
3536 {
3537 pattern_ty p;
3538 p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
3539 if (!p)
3540 return NULL;
3541 p->kind = MatchStar_kind;
3542 p->v.MatchStar.name = name;
3543 p->lineno = lineno;
3544 p->col_offset = col_offset;
3545 p->end_lineno = end_lineno;
3546 p->end_col_offset = end_col_offset;
3547 return p;
3548 }
3549
3550 pattern_ty
3551 4 _PyAST_MatchAs(pattern_ty pattern, identifier name, int lineno, int col_offset,
3552 int end_lineno, int end_col_offset, PyArena *arena)
3553 {
3554 pattern_ty p;
3555 4 p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
3556
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!p)
3557 return NULL;
3558 4 p->kind = MatchAs_kind;
3559 4 p->v.MatchAs.pattern = pattern;
3560 4 p->v.MatchAs.name = name;
3561 4 p->lineno = lineno;
3562 4 p->col_offset = col_offset;
3563 4 p->end_lineno = end_lineno;
3564 4 p->end_col_offset = end_col_offset;
3565 4 return p;
3566 }
3567
3568 pattern_ty
3569 _PyAST_MatchOr(asdl_pattern_seq * patterns, int lineno, int col_offset, int
3570 end_lineno, int end_col_offset, PyArena *arena)
3571 {
3572 pattern_ty p;
3573 p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
3574 if (!p)
3575 return NULL;
3576 p->kind = MatchOr_kind;
3577 p->v.MatchOr.patterns = patterns;
3578 p->lineno = lineno;
3579 p->col_offset = col_offset;
3580 p->end_lineno = end_lineno;
3581 p->end_col_offset = end_col_offset;
3582 return p;
3583 }
3584
3585 type_ignore_ty
3586 _PyAST_TypeIgnore(int lineno, string tag, PyArena *arena)
3587 {
3588 type_ignore_ty p;
3589 if (!tag) {
3590 PyErr_SetString(PyExc_ValueError,
3591 "field 'tag' is required for TypeIgnore");
3592 return NULL;
3593 }
3594 p = (type_ignore_ty)_PyArena_Malloc(arena, sizeof(*p));
3595 if (!p)
3596 return NULL;
3597 p->kind = TypeIgnore_kind;
3598 p->v.TypeIgnore.lineno = lineno;
3599 p->v.TypeIgnore.tag = tag;
3600 return p;
3601 }
3602
3603
3604 PyObject*
3605 3727 ast2obj_mod(struct ast_state *state, void* _o)
3606 {
3607 3727 mod_ty o = (mod_ty)_o;
3608 3727 PyObject *result = NULL, *value = NULL;
3609 PyTypeObject *tp;
3610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3727 times.
3727 if (!o) {
3611 Py_RETURN_NONE;
3612 }
3613
2/5
✓ Branch 0 taken 2782 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 945 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
3727 switch (o->kind) {
3614 2782 case Module_kind:
3615 2782 tp = (PyTypeObject *)state->Module_type;
3616 2782 result = PyType_GenericNew(tp, NULL, NULL);
3617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2782 times.
2782 if (!result) goto failed;
3618 2782 value = ast2obj_list(state, (asdl_seq*)o->v.Module.body, ast2obj_stmt);
3619
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2782 times.
2782 if (!value) goto failed;
3620
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 2782 times.
2782 if (PyObject_SetAttr(result, state->body, value) == -1)
3621 goto failed;
3622 2782 Py_DECREF(value);
3623 2782 value = ast2obj_list(state, (asdl_seq*)o->v.Module.type_ignores,
3624 ast2obj_type_ignore);
3625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2782 times.
2782 if (!value) goto failed;
3626
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 2782 times.
2782 if (PyObject_SetAttr(result, state->type_ignores, value) == -1)
3627 goto failed;
3628 2782 Py_DECREF(value);
3629 2782 break;
3630 case Interactive_kind:
3631 tp = (PyTypeObject *)state->Interactive_type;
3632 result = PyType_GenericNew(tp, NULL, NULL);
3633 if (!result) goto failed;
3634 value = ast2obj_list(state, (asdl_seq*)o->v.Interactive.body,
3635 ast2obj_stmt);
3636 if (!value) goto failed;
3637 if (PyObject_SetAttr(result, state->body, value) == -1)
3638 goto failed;
3639 Py_DECREF(value);
3640 break;
3641 945 case Expression_kind:
3642 945 tp = (PyTypeObject *)state->Expression_type;
3643 945 result = PyType_GenericNew(tp, NULL, NULL);
3644
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 945 times.
945 if (!result) goto failed;
3645 945 value = ast2obj_expr(state, o->v.Expression.body);
3646
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 945 times.
945 if (!value) goto failed;
3647
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 945 times.
945 if (PyObject_SetAttr(result, state->body, value) == -1)
3648 goto failed;
3649 945 Py_DECREF(value);
3650 945 break;
3651 case FunctionType_kind:
3652 tp = (PyTypeObject *)state->FunctionType_type;
3653 result = PyType_GenericNew(tp, NULL, NULL);
3654 if (!result) goto failed;
3655 value = ast2obj_list(state, (asdl_seq*)o->v.FunctionType.argtypes,
3656 ast2obj_expr);
3657 if (!value) goto failed;
3658 if (PyObject_SetAttr(result, state->argtypes, value) == -1)
3659 goto failed;
3660 Py_DECREF(value);
3661 value = ast2obj_expr(state, o->v.FunctionType.returns);
3662 if (!value) goto failed;
3663 if (PyObject_SetAttr(result, state->returns, value) == -1)
3664 goto failed;
3665 Py_DECREF(value);
3666 break;
3667 }
3668 3727 return result;
3669 failed:
3670 Py_XDECREF(value);
3671 Py_XDECREF(result);
3672 return NULL;
3673 }
3674
3675 PyObject*
3676 4390 ast2obj_stmt(struct ast_state *state, void* _o)
3677 {
3678 4390 stmt_ty o = (stmt_ty)_o;
3679 4390 PyObject *result = NULL, *value = NULL;
3680 PyTypeObject *tp;
3681
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4390 times.
4390 if (!o) {
3682 Py_RETURN_NONE;
3683 }
3684
14/28
✓ Branch 0 taken 340 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 260 times.
✓ Branch 4 taken 70 times.
✓ Branch 5 taken 1268 times.
✓ Branch 6 taken 44 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 140 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 558 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 30 times.
✓ Branch 16 taken 70 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 64 times.
✓ Branch 20 taken 80 times.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✓ Branch 23 taken 1116 times.
✓ Branch 24 taken 334 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
4390 switch (o->kind) {
3685 340 case FunctionDef_kind:
3686 340 tp = (PyTypeObject *)state->FunctionDef_type;
3687 340 result = PyType_GenericNew(tp, NULL, NULL);
3688
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 340 times.
340 if (!result) goto failed;
3689 340 value = ast2obj_identifier(state, o->v.FunctionDef.name);
3690
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 340 times.
340 if (!value) goto failed;
3691
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 340 times.
340 if (PyObject_SetAttr(result, state->name, value) == -1)
3692 goto failed;
3693 340 Py_DECREF(value);
3694 340 value = ast2obj_arguments(state, o->v.FunctionDef.args);
3695
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 340 times.
340 if (!value) goto failed;
3696
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 340 times.
340 if (PyObject_SetAttr(result, state->args, value) == -1)
3697 goto failed;
3698 340 Py_DECREF(value);
3699 340 value = ast2obj_list(state, (asdl_seq*)o->v.FunctionDef.body,
3700 ast2obj_stmt);
3701
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 340 times.
340 if (!value) goto failed;
3702
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 340 times.
340 if (PyObject_SetAttr(result, state->body, value) == -1)
3703 goto failed;
3704 340 Py_DECREF(value);
3705 340 value = ast2obj_list(state, (asdl_seq*)o->v.FunctionDef.decorator_list,
3706 ast2obj_expr);
3707
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 340 times.
340 if (!value) goto failed;
3708
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 340 times.
340 if (PyObject_SetAttr(result, state->decorator_list, value) == -1)
3709 goto failed;
3710 340 Py_DECREF(value);
3711 340 value = ast2obj_expr(state, o->v.FunctionDef.returns);
3712
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 340 times.
340 if (!value) goto failed;
3713
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 340 times.
340 if (PyObject_SetAttr(result, state->returns, value) == -1)
3714 goto failed;
3715 340 Py_DECREF(value);
3716 340 value = ast2obj_string(state, o->v.FunctionDef.type_comment);
3717
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 340 times.
340 if (!value) goto failed;
3718
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 340 times.
340 if (PyObject_SetAttr(result, state->type_comment, value) == -1)
3719 goto failed;
3720 340 Py_DECREF(value);
3721 340 break;
3722 case AsyncFunctionDef_kind:
3723 tp = (PyTypeObject *)state->AsyncFunctionDef_type;
3724 result = PyType_GenericNew(tp, NULL, NULL);
3725 if (!result) goto failed;
3726 value = ast2obj_identifier(state, o->v.AsyncFunctionDef.name);
3727 if (!value) goto failed;
3728 if (PyObject_SetAttr(result, state->name, value) == -1)
3729 goto failed;
3730 Py_DECREF(value);
3731 value = ast2obj_arguments(state, o->v.AsyncFunctionDef.args);
3732 if (!value) goto failed;
3733 if (PyObject_SetAttr(result, state->args, value) == -1)
3734 goto failed;
3735 Py_DECREF(value);
3736 value = ast2obj_list(state, (asdl_seq*)o->v.AsyncFunctionDef.body,
3737 ast2obj_stmt);
3738 if (!value) goto failed;
3739 if (PyObject_SetAttr(result, state->body, value) == -1)
3740 goto failed;
3741 Py_DECREF(value);
3742 value = ast2obj_list(state,
3743 (asdl_seq*)o->v.AsyncFunctionDef.decorator_list,
3744 ast2obj_expr);
3745 if (!value) goto failed;
3746 if (PyObject_SetAttr(result, state->decorator_list, value) == -1)
3747 goto failed;
3748 Py_DECREF(value);
3749 value = ast2obj_expr(state, o->v.AsyncFunctionDef.returns);
3750 if (!value) goto failed;
3751 if (PyObject_SetAttr(result, state->returns, value) == -1)
3752 goto failed;
3753 Py_DECREF(value);
3754 value = ast2obj_string(state, o->v.AsyncFunctionDef.type_comment);
3755 if (!value) goto failed;
3756 if (PyObject_SetAttr(result, state->type_comment, value) == -1)
3757 goto failed;
3758 Py_DECREF(value);
3759 break;
3760 16 case ClassDef_kind:
3761 16 tp = (PyTypeObject *)state->ClassDef_type;
3762 16 result = PyType_GenericNew(tp, NULL, NULL);
3763
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if (!result) goto failed;
3764 16 value = ast2obj_identifier(state, o->v.ClassDef.name);
3765
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if (!value) goto failed;
3766
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
16 if (PyObject_SetAttr(result, state->name, value) == -1)
3767 goto failed;
3768 16 Py_DECREF(value);
3769 16 value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.bases,
3770 ast2obj_expr);
3771
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if (!value) goto failed;
3772
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
16 if (PyObject_SetAttr(result, state->bases, value) == -1)
3773 goto failed;
3774 16 Py_DECREF(value);
3775 16 value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.keywords,
3776 ast2obj_keyword);
3777
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if (!value) goto failed;
3778
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
16 if (PyObject_SetAttr(result, state->keywords, value) == -1)
3779 goto failed;
3780 16 Py_DECREF(value);
3781 16 value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.body,
3782 ast2obj_stmt);
3783
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if (!value) goto failed;
3784
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
16 if (PyObject_SetAttr(result, state->body, value) == -1)
3785 goto failed;
3786 16 Py_DECREF(value);
3787 16 value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.decorator_list,
3788 ast2obj_expr);
3789
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if (!value) goto failed;
3790
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
16 if (PyObject_SetAttr(result, state->decorator_list, value) == -1)
3791 goto failed;
3792 16 Py_DECREF(value);
3793 16 break;
3794 260 case Return_kind:
3795 260 tp = (PyTypeObject *)state->Return_type;
3796 260 result = PyType_GenericNew(tp, NULL, NULL);
3797
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 260 times.
260 if (!result) goto failed;
3798 260 value = ast2obj_expr(state, o->v.Return.value);
3799
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 260 times.
260 if (!value) goto failed;
3800
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 260 times.
260 if (PyObject_SetAttr(result, state->value, value) == -1)
3801 goto failed;
3802 260 Py_DECREF(value);
3803 260 break;
3804 70 case Delete_kind:
3805 70 tp = (PyTypeObject *)state->Delete_type;
3806 70 result = PyType_GenericNew(tp, NULL, NULL);
3807
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 if (!result) goto failed;
3808 70 value = ast2obj_list(state, (asdl_seq*)o->v.Delete.targets,
3809 ast2obj_expr);
3810
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 if (!value) goto failed;
3811
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 70 times.
70 if (PyObject_SetAttr(result, state->targets, value) == -1)
3812 goto failed;
3813 70 Py_DECREF(value);
3814 70 break;
3815 1268 case Assign_kind:
3816 1268 tp = (PyTypeObject *)state->Assign_type;
3817 1268 result = PyType_GenericNew(tp, NULL, NULL);
3818
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1268 times.
1268 if (!result) goto failed;
3819 1268 value = ast2obj_list(state, (asdl_seq*)o->v.Assign.targets,
3820 ast2obj_expr);
3821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1268 times.
1268 if (!value) goto failed;
3822
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1268 times.
1268 if (PyObject_SetAttr(result, state->targets, value) == -1)
3823 goto failed;
3824 1268 Py_DECREF(value);
3825 1268 value = ast2obj_expr(state, o->v.Assign.value);
3826
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1268 times.
1268 if (!value) goto failed;
3827
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1268 times.
1268 if (PyObject_SetAttr(result, state->value, value) == -1)
3828 goto failed;
3829 1268 Py_DECREF(value);
3830 1268 value = ast2obj_string(state, o->v.Assign.type_comment);
3831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1268 times.
1268 if (!value) goto failed;
3832
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1268 times.
1268 if (PyObject_SetAttr(result, state->type_comment, value) == -1)
3833 goto failed;
3834 1268 Py_DECREF(value);
3835 1268 break;
3836 44 case AugAssign_kind:
3837 44 tp = (PyTypeObject *)state->AugAssign_type;
3838 44 result = PyType_GenericNew(tp, NULL, NULL);
3839
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 if (!result) goto failed;
3840 44 value = ast2obj_expr(state, o->v.AugAssign.target);
3841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 if (!value) goto failed;
3842
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 44 times.
44 if (PyObject_SetAttr(result, state->target, value) == -1)
3843 goto failed;
3844 44 Py_DECREF(value);
3845 44 value = ast2obj_operator(state, o->v.AugAssign.op);
3846
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 if (!value) goto failed;
3847
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 44 times.
44 if (PyObject_SetAttr(result, state->op, value) == -1)
3848 goto failed;
3849 44 Py_DECREF(value);
3850 44 value = ast2obj_expr(state, o->v.AugAssign.value);
3851
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 if (!value) goto failed;
3852
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 44 times.
44 if (PyObject_SetAttr(result, state->value, value) == -1)
3853 goto failed;
3854 44 Py_DECREF(value);
3855 44 break;
3856 case AnnAssign_kind:
3857 tp = (PyTypeObject *)state->AnnAssign_type;
3858 result = PyType_GenericNew(tp, NULL, NULL);
3859 if (!result) goto failed;
3860 value = ast2obj_expr(state, o->v.AnnAssign.target);
3861 if (!value) goto failed;
3862 if (PyObject_SetAttr(result, state->target, value) == -1)
3863 goto failed;
3864 Py_DECREF(value);
3865 value = ast2obj_expr(state, o->v.AnnAssign.annotation);
3866 if (!value) goto failed;
3867 if (PyObject_SetAttr(result, state->annotation, value) == -1)
3868 goto failed;
3869 Py_DECREF(value);
3870 value = ast2obj_expr(state, o->v.AnnAssign.value);
3871 if (!value) goto failed;
3872 if (PyObject_SetAttr(result, state->value, value) == -1)
3873 goto failed;
3874 Py_DECREF(value);
3875 value = ast2obj_int(state, o->v.AnnAssign.simple);
3876 if (!value) goto failed;
3877 if (PyObject_SetAttr(result, state->simple, value) == -1)
3878 goto failed;
3879 Py_DECREF(value);
3880 break;
3881 140 case For_kind:
3882 140 tp = (PyTypeObject *)state->For_type;
3883 140 result = PyType_GenericNew(tp, NULL, NULL);
3884
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if (!result) goto failed;
3885 140 value = ast2obj_expr(state, o->v.For.target);
3886
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if (!value) goto failed;
3887
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 140 times.
140 if (PyObject_SetAttr(result, state->target, value) == -1)
3888 goto failed;
3889 140 Py_DECREF(value);
3890 140 value = ast2obj_expr(state, o->v.For.iter);
3891
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if (!value) goto failed;
3892
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 140 times.
140 if (PyObject_SetAttr(result, state->iter, value) == -1)
3893 goto failed;
3894 140 Py_DECREF(value);
3895 140 value = ast2obj_list(state, (asdl_seq*)o->v.For.body, ast2obj_stmt);
3896
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if (!value) goto failed;
3897
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 140 times.
140 if (PyObject_SetAttr(result, state->body, value) == -1)
3898 goto failed;
3899 140 Py_DECREF(value);
3900 140 value = ast2obj_list(state, (asdl_seq*)o->v.For.orelse, ast2obj_stmt);
3901
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if (!value) goto failed;
3902
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 140 times.
140 if (PyObject_SetAttr(result, state->orelse, value) == -1)
3903 goto failed;
3904 140 Py_DECREF(value);
3905 140 value = ast2obj_string(state, o->v.For.type_comment);
3906
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if (!value) goto failed;
3907
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 140 times.
140 if (PyObject_SetAttr(result, state->type_comment, value) == -1)
3908 goto failed;
3909 140 Py_DECREF(value);
3910 140 break;
3911 case AsyncFor_kind:
3912 tp = (PyTypeObject *)state->AsyncFor_type;
3913 result = PyType_GenericNew(tp, NULL, NULL);
3914 if (!result) goto failed;
3915 value = ast2obj_expr(state, o->v.AsyncFor.target);
3916 if (!value) goto failed;
3917 if (PyObject_SetAttr(result, state->target, value) == -1)
3918 goto failed;
3919 Py_DECREF(value);
3920 value = ast2obj_expr(state, o->v.AsyncFor.iter);
3921 if (!value) goto failed;
3922 if (PyObject_SetAttr(result, state->iter, value) == -1)
3923 goto failed;
3924 Py_DECREF(value);
3925 value = ast2obj_list(state, (asdl_seq*)o->v.AsyncFor.body,
3926 ast2obj_stmt);
3927 if (!value) goto failed;
3928 if (PyObject_SetAttr(result, state->body, value) == -1)
3929 goto failed;
3930 Py_DECREF(value);
3931 value = ast2obj_list(state, (asdl_seq*)o->v.AsyncFor.orelse,
3932 ast2obj_stmt);
3933 if (!value) goto failed;
3934 if (PyObject_SetAttr(result, state->orelse, value) == -1)
3935 goto failed;
3936 Py_DECREF(value);
3937 value = ast2obj_string(state, o->v.AsyncFor.type_comment);
3938 if (!value) goto failed;
3939 if (PyObject_SetAttr(result, state->type_comment, value) == -1)
3940 goto failed;
3941 Py_DECREF(value);
3942 break;
3943 case While_kind:
3944 tp = (PyTypeObject *)state->While_type;
3945 result = PyType_GenericNew(tp, NULL, NULL);
3946 if (!result) goto failed;
3947 value = ast2obj_expr(state, o->v.While.test);
3948 if (!value) goto failed;
3949 if (PyObject_SetAttr(result, state->test, value) == -1)
3950 goto failed;
3951 Py_DECREF(value);
3952 value = ast2obj_list(state, (asdl_seq*)o->v.While.body, ast2obj_stmt);
3953 if (!value) goto failed;
3954 if (PyObject_SetAttr(result, state->body, value) == -1)
3955 goto failed;
3956 Py_DECREF(value);
3957 value = ast2obj_list(state, (asdl_seq*)o->v.While.orelse, ast2obj_stmt);
3958 if (!value) goto failed;
3959 if (PyObject_SetAttr(result, state->orelse, value) == -1)
3960 goto failed;
3961 Py_DECREF(value);
3962 break;
3963 558 case If_kind:
3964 558 tp = (PyTypeObject *)state->If_type;
3965 558 result = PyType_GenericNew(tp, NULL, NULL);
3966
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 558 times.
558 if (!result) goto failed;
3967 558 value = ast2obj_expr(state, o->v.If.test);
3968
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 558 times.
558 if (!value) goto failed;
3969
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 558 times.
558 if (PyObject_SetAttr(result, state->test, value) == -1)
3970 goto failed;
3971 558 Py_DECREF(value);
3972 558 value = ast2obj_list(state, (asdl_seq*)o->v.If.body, ast2obj_stmt);
3973
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 558 times.
558 if (!value) goto failed;
3974
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 558 times.
558 if (PyObject_SetAttr(result, state->body, value) == -1)
3975 goto failed;
3976 558 Py_DECREF(value);
3977 558 value = ast2obj_list(state, (asdl_seq*)o->v.If.orelse, ast2obj_stmt);
3978
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 558 times.
558 if (!value) goto failed;
3979
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 558 times.
558 if (PyObject_SetAttr(result, state->orelse, value) == -1)
3980 goto failed;
3981 558 Py_DECREF(value);
3982 558 break;
3983 case With_kind:
3984 tp = (PyTypeObject *)state->With_type;
3985 result = PyType_GenericNew(tp, NULL, NULL);
3986 if (!result) goto failed;
3987 value = ast2obj_list(state, (asdl_seq*)o->v.With.items,
3988 ast2obj_withitem);
3989 if (!value) goto failed;
3990 if (PyObject_SetAttr(result, state->items, value) == -1)
3991 goto failed;
3992 Py_DECREF(value);
3993 value = ast2obj_list(state, (asdl_seq*)o->v.With.body, ast2obj_stmt);
3994 if (!value) goto failed;
3995 if (PyObject_SetAttr(result, state->body, value) == -1)
3996 goto failed;
3997 Py_DECREF(value);
3998 value = ast2obj_string(state, o->v.With.type_comment);
3999 if (!value) goto failed;
4000 if (PyObject_SetAttr(result, state->type_comment, value) == -1)
4001 goto failed;
4002 Py_DECREF(value);
4003 break;
4004 case AsyncWith_kind:
4005 tp = (PyTypeObject *)state->AsyncWith_type;
4006 result = PyType_GenericNew(tp, NULL, NULL);
4007 if (!result) goto failed;
4008 value = ast2obj_list(state, (asdl_seq*)o->v.AsyncWith.items,
4009 ast2obj_withitem);
4010 if (!value) goto failed;
4011 if (PyObject_SetAttr(result, state->items, value) == -1)
4012 goto failed;
4013 Py_DECREF(value);
4014 value = ast2obj_list(state, (asdl_seq*)o->v.AsyncWith.body,
4015 ast2obj_stmt);
4016 if (!value) goto failed;
4017 if (PyObject_SetAttr(result, state->body, value) == -1)
4018 goto failed;
4019 Py_DECREF(value);
4020 value = ast2obj_string(state, o->v.AsyncWith.type_comment);
4021 if (!value) goto failed;
4022 if (PyObject_SetAttr(result, state->type_comment, value) == -1)
4023 goto failed;
4024 Py_DECREF(value);
4025 break;
4026 case Match_kind:
4027 tp = (PyTypeObject *)state->Match_type;
4028 result = PyType_GenericNew(tp, NULL, NULL);
4029 if (!result) goto failed;
4030 value = ast2obj_expr(state, o->v.Match.subject);
4031 if (!value) goto failed;
4032 if (PyObject_SetAttr(result, state->subject, value) == -1)
4033 goto failed;
4034 Py_DECREF(value);
4035 value = ast2obj_list(state, (asdl_seq*)o->v.Match.cases,
4036 ast2obj_match_case);
4037 if (!value) goto failed;
4038 if (PyObject_SetAttr(result, state->cases, value) == -1)
4039 goto failed;
4040 Py_DECREF(value);
4041 break;
4042 30 case Raise_kind:
4043 30 tp = (PyTypeObject *)state->Raise_type;
4044 30 result = PyType_GenericNew(tp, NULL, NULL);
4045
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if (!result) goto failed;
4046 30 value = ast2obj_expr(state, o->v.Raise.exc);
4047
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if (!value) goto failed;
4048
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
30 if (PyObject_SetAttr(result, state->exc, value) == -1)
4049 goto failed;
4050 30 Py_DECREF(value);
4051 30 value = ast2obj_expr(state, o->v.Raise.cause);
4052
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if (!value) goto failed;
4053
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
30 if (PyObject_SetAttr(result, state->cause, value) == -1)
4054 goto failed;
4055 30 Py_DECREF(value);
4056 30 break;
4057 70 case Try_kind:
4058 70 tp = (PyTypeObject *)state->Try_type;
4059 70 result = PyType_GenericNew(tp, NULL, NULL);
4060
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 if (!result) goto failed;
4061 70 value = ast2obj_list(state, (asdl_seq*)o->v.Try.body, ast2obj_stmt);
4062
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 if (!value) goto failed;
4063
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 70 times.
70 if (PyObject_SetAttr(result, state->body, value) == -1)
4064 goto failed;
4065 70 Py_DECREF(value);
4066 70 value = ast2obj_list(state, (asdl_seq*)o->v.Try.handlers,
4067 ast2obj_excepthandler);
4068
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 if (!value) goto failed;
4069
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 70 times.
70 if (PyObject_SetAttr(result, state->handlers, value) == -1)
4070 goto failed;
4071 70 Py_DECREF(value);
4072 70 value = ast2obj_list(state, (asdl_seq*)o->v.Try.orelse, ast2obj_stmt);
4073
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 if (!value) goto failed;
4074
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 70 times.
70 if (PyObject_SetAttr(result, state->orelse, value) == -1)
4075 goto failed;
4076 70 Py_DECREF(value);
4077 70 value = ast2obj_list(state, (asdl_seq*)o->v.Try.finalbody,
4078 ast2obj_stmt);
4079
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 if (!value) goto failed;
4080
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 70 times.
70 if (PyObject_SetAttr(result, state->finalbody, value) == -1)
4081 goto failed;
4082 70 Py_DECREF(value);
4083 70 break;
4084 case TryStar_kind:
4085 tp = (PyTypeObject *)state->TryStar_type;
4086 result = PyType_GenericNew(tp, NULL, NULL);
4087 if (!result) goto failed;
4088 value = ast2obj_list(state, (asdl_seq*)o->v.TryStar.body, ast2obj_stmt);
4089 if (!value) goto failed;
4090 if (PyObject_SetAttr(result, state->body, value) == -1)
4091 goto failed;
4092 Py_DECREF(value);
4093 value = ast2obj_list(state, (asdl_seq*)o->v.TryStar.handlers,
4094 ast2obj_excepthandler);
4095 if (!value) goto failed;
4096 if (PyObject_SetAttr(result, state->handlers, value) == -1)
4097 goto failed;
4098 Py_DECREF(value);
4099 value = ast2obj_list(state, (asdl_seq*)o->v.TryStar.orelse,
4100 ast2obj_stmt);
4101 if (!value) goto failed;
4102 if (PyObject_SetAttr(result, state->orelse, value) == -1)
4103 goto failed;
4104 Py_DECREF(value);
4105 value = ast2obj_list(state, (asdl_seq*)o->v.TryStar.finalbody,
4106 ast2obj_stmt);
4107 if (!value) goto failed;
4108 if (PyObject_SetAttr(result, state->finalbody, value) == -1)
4109 goto failed;
4110 Py_DECREF(value);
4111 break;
4112 case Assert_kind:
4113 tp = (PyTypeObject *)state->Assert_type;
4114 result = PyType_GenericNew(tp, NULL, NULL);
4115 if (!result) goto failed;
4116 value = ast2obj_expr(state, o->v.Assert.test);
4117 if (!value) goto failed;
4118 if (PyObject_SetAttr(result, state->test, value) == -1)
4119 goto failed;
4120 Py_DECREF(value);
4121 value = ast2obj_expr(state, o->v.Assert.msg);
4122 if (!value) goto failed;
4123 if (PyObject_SetAttr(result, state->msg, value) == -1)
4124 goto failed;
4125 Py_DECREF(value);
4126 break;
4127 64 case Import_kind:
4128 64 tp = (PyTypeObject *)state->Import_type;
4129 64 result = PyType_GenericNew(tp, NULL, NULL);
4130
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if (!result) goto failed;
4131 64 value = ast2obj_list(state, (asdl_seq*)o->v.Import.names,
4132 ast2obj_alias);
4133
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if (!value) goto failed;
4134
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 64 times.
64 if (PyObject_SetAttr(result, state->names, value) == -1)
4135 goto failed;
4136 64 Py_DECREF(value);
4137 64 break;
4138 80 case ImportFrom_kind:
4139 80 tp = (PyTypeObject *)state->ImportFrom_type;
4140 80 result = PyType_GenericNew(tp, NULL, NULL);
4141
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if (!result) goto failed;
4142 80 value = ast2obj_identifier(state, o->v.ImportFrom.module);
4143
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if (!value) goto failed;
4144
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
80 if (PyObject_SetAttr(result, state->module, value) == -1)
4145 goto failed;
4146 80 Py_DECREF(value);
4147 80 value = ast2obj_list(state, (asdl_seq*)o->v.ImportFrom.names,
4148 ast2obj_alias);
4149
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if (!value) goto failed;
4150
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
80 if (PyObject_SetAttr(result, state->names, value) == -1)
4151 goto failed;
4152 80 Py_DECREF(value);
4153 80 value = ast2obj_int(state, o->v.ImportFrom.level);
4154
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if (!value) goto failed;
4155
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
80 if (PyObject_SetAttr(result, state->level, value) == -1)
4156 goto failed;
4157 80 Py_DECREF(value);
4158 80 break;
4159 case Global_kind:
4160 tp = (PyTypeObject *)state->Global_type;
4161 result = PyType_GenericNew(tp, NULL, NULL);
4162 if (!result) goto failed;
4163 value = ast2obj_list(state, (asdl_seq*)o->v.Global.names,
4164 ast2obj_identifier);
4165 if (!value) goto failed;
4166 if (PyObject_SetAttr(result, state->names, value) == -1)
4167 goto failed;
4168 Py_DECREF(value);
4169 break;
4170 case Nonlocal_kind:
4171 tp = (PyTypeObject *)state->Nonlocal_type;
4172 result = PyType_GenericNew(tp, NULL, NULL);
4173 if (!result) goto failed;
4174 value = ast2obj_list(state, (asdl_seq*)o->v.Nonlocal.names,
4175 ast2obj_identifier);
4176 if (!value) goto failed;
4177 if (PyObject_SetAttr(result, state->names, value) == -1)
4178 goto failed;
4179 Py_DECREF(value);
4180 break;
4181 1116 case Expr_kind:
4182 1116 tp = (PyTypeObject *)state->Expr_type;
4183 1116 result = PyType_GenericNew(tp, NULL, NULL);
4184
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1116 times.
1116 if (!result) goto failed;
4185 1116 value = ast2obj_expr(state, o->v.Expr.value);
4186
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1116 times.
1116 if (!value) goto failed;
4187
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1116 times.
1116 if (PyObject_SetAttr(result, state->value, value) == -1)
4188 goto failed;
4189 1116 Py_DECREF(value);
4190 1116 break;
4191 334 case Pass_kind:
4192 334 tp = (PyTypeObject *)state->Pass_type;
4193 334 result = PyType_GenericNew(tp, NULL, NULL);
4194
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 334 times.
334 if (!result) goto failed;
4195 334 break;
4196 case Break_kind:
4197 tp = (PyTypeObject *)state->Break_type;
4198 result = PyType_GenericNew(tp, NULL, NULL);
4199 if (!result) goto failed;
4200 break;
4201 case Continue_kind:
4202 tp = (PyTypeObject *)state->Continue_type;
4203 result = PyType_GenericNew(tp, NULL, NULL);
4204 if (!result) goto failed;
4205 break;
4206 }
4207 4390 value = ast2obj_int(state, o->lineno);
4208
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4390 times.
4390 if (!value) goto failed;
4209
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4390 times.
4390 if (PyObject_SetAttr(result, state->lineno, value) < 0)
4210 goto failed;
4211 4390 Py_DECREF(value);
4212 4390 value = ast2obj_int(state, o->col_offset);
4213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4390 times.
4390 if (!value) goto failed;
4214
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4390 times.
4390 if (PyObject_SetAttr(result, state->col_offset, value) < 0)
4215 goto failed;
4216 4390 Py_DECREF(value);
4217 4390 value = ast2obj_int(state, o->end_lineno);
4218
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4390 times.
4390 if (!value) goto failed;
4219
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4390 times.
4390 if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
4220 goto failed;
4221 4390 Py_DECREF(value);
4222 4390 value = ast2obj_int(state, o->end_col_offset);
4223
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4390 times.
4390 if (!value) goto failed;
4224
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4390 times.
4390 if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
4225 goto failed;
4226 4390 Py_DECREF(value);
4227 4390 return result;
4228 failed:
4229 Py_XDECREF(value);
4230 Py_XDECREF(result);
4231 return NULL;
4232 }
4233
4234 PyObject*
4235 461287 ast2obj_expr(struct ast_state *state, void* _o)
4236 {
4237 461287 expr_ty o = (expr_ty)_o;
4238 461287 PyObject *result = NULL, *value = NULL;
4239 PyTypeObject *tp;
4240
2/2
✓ Branch 0 taken 660 times.
✓ Branch 1 taken 460627 times.
461287 if (!o) {
4241 660 Py_RETURN_NONE;
4242 }
4243
18/28
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 88 times.
✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 44 times.
✓ Branch 6 taken 44 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 12 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 4 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 734 times.
✓ Branch 16 taken 2390 times.
✓ Branch 17 taken 16 times.
✓ Branch 18 taken 8 times.
✓ Branch 19 taken 446440 times.
✓ Branch 20 taken 1092 times.
✓ Branch 21 taken 366 times.
✓ Branch 22 taken 4 times.
✓ Branch 23 taken 8994 times.
✓ Branch 24 taken 56 times.
✓ Branch 25 taken 249 times.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
460627 switch (o->kind) {
4244 78 case BoolOp_kind:
4245 78 tp = (PyTypeObject *)state->BoolOp_type;
4246 78 result = PyType_GenericNew(tp, NULL, NULL);
4247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 78 times.
78 if (!result) goto failed;
4248 78 value = ast2obj_boolop(state, o->v.BoolOp.op);
4249
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 78 times.
78 if (!value) goto failed;
4250
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 78 times.
78 if (PyObject_SetAttr(result, state->op, value) == -1)
4251 goto failed;
4252 78 Py_DECREF(value);
4253 78 value = ast2obj_list(state, (asdl_seq*)o->v.BoolOp.values,
4254 ast2obj_expr);
4255
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 78 times.
78 if (!value) goto failed;
4256
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 78 times.
78 if (PyObject_SetAttr(result, state->values, value) == -1)
4257 goto failed;
4258 78 Py_DECREF(value);
4259 78 break;
4260 case NamedExpr_kind:
4261 tp = (PyTypeObject *)state->NamedExpr_type;
4262 result = PyType_GenericNew(tp, NULL, NULL);
4263 if (!result) goto failed;
4264 value = ast2obj_expr(state, o->v.NamedExpr.target);
4265 if (!value) goto failed;
4266 if (PyObject_SetAttr(result, state->target, value) == -1)
4267 goto failed;
4268 Py_DECREF(value);
4269 value = ast2obj_expr(state, o->v.NamedExpr.value);
4270 if (!value) goto failed;
4271 if (PyObject_SetAttr(result, state->value, value) == -1)
4272 goto failed;
4273 Py_DECREF(value);
4274 break;
4275 88 case BinOp_kind:
4276 88 tp = (PyTypeObject *)state->BinOp_type;
4277 88 result = PyType_GenericNew(tp, NULL, NULL);
4278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if (!result) goto failed;
4279 88 value = ast2obj_expr(state, o->v.BinOp.left);
4280
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if (!value) goto failed;
4281
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 88 times.
88 if (PyObject_SetAttr(result, state->left, value) == -1)
4282 goto failed;
4283 88 Py_DECREF(value);
4284 88 value = ast2obj_operator(state, o->v.BinOp.op);
4285
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if (!value) goto failed;
4286
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 88 times.
88 if (PyObject_SetAttr(result, state->op, value) == -1)
4287 goto failed;
4288 88 Py_DECREF(value);
4289 88 value = ast2obj_expr(state, o->v.BinOp.right);
4290
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if (!value) goto failed;
4291
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 88 times.
88 if (PyObject_SetAttr(result, state->right, value) == -1)
4292 goto failed;
4293 88 Py_DECREF(value);
4294 88 break;
4295 8 case UnaryOp_kind:
4296 8 tp = (PyTypeObject *)state->UnaryOp_type;
4297 8 result = PyType_GenericNew(tp, NULL, NULL);
4298
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if (!result) goto failed;
4299 8 value = ast2obj_unaryop(state, o->v.UnaryOp.op);
4300
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if (!value) goto failed;
4301
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
8 if (PyObject_SetAttr(result, state->op, value) == -1)
4302 goto failed;
4303 8 Py_DECREF(value);
4304 8 value = ast2obj_expr(state, o->v.UnaryOp.operand);
4305
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if (!value) goto failed;
4306
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
8 if (PyObject_SetAttr(result, state->operand, value) == -1)
4307 goto failed;
4308 8 Py_DECREF(value);
4309 8 break;
4310 case Lambda_kind:
4311 tp = (PyTypeObject *)state->Lambda_type;
4312 result = PyType_GenericNew(tp, NULL, NULL);
4313 if (!result) goto failed;
4314 value = ast2obj_arguments(state, o->v.Lambda.args);
4315 if (!value) goto failed;
4316 if (PyObject_SetAttr(result, state->args, value) == -1)
4317 goto failed;
4318 Py_DECREF(value);
4319 value = ast2obj_expr(state, o->v.Lambda.body);
4320 if (!value) goto failed;
4321 if (PyObject_SetAttr(result, state->body, value) == -1)
4322 goto failed;
4323 Py_DECREF(value);
4324 break;
4325 44 case IfExp_kind:
4326 44 tp = (PyTypeObject *)state->IfExp_type;
4327 44 result = PyType_GenericNew(tp, NULL, NULL);
4328
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 if (!result) goto failed;
4329 44 value = ast2obj_expr(state, o->v.IfExp.test);
4330
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 if (!value) goto failed;
4331
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 44 times.
44 if (PyObject_SetAttr(result, state->test, value) == -1)
4332 goto failed;
4333 44 Py_DECREF(value);
4334 44 value = ast2obj_expr(state, o->v.IfExp.body);
4335
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 if (!value) goto failed;
4336
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 44 times.
44 if (PyObject_SetAttr(result, state->body, value) == -1)
4337 goto failed;
4338 44 Py_DECREF(value);
4339 44 value = ast2obj_expr(state, o->v.IfExp.orelse);
4340
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 if (!value) goto failed;
4341
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 44 times.
44 if (PyObject_SetAttr(result, state->orelse, value) == -1)
4342 goto failed;
4343 44 Py_DECREF(value);
4344 44 break;
4345 44 case Dict_kind:
4346 44 tp = (PyTypeObject *)state->Dict_type;
4347 44 result = PyType_GenericNew(tp, NULL, NULL);
4348
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 if (!result) goto failed;
4349 44 value = ast2obj_list(state, (asdl_seq*)o->v.Dict.keys, ast2obj_expr);
4350
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 if (!value) goto failed;
4351
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 44 times.
44 if (PyObject_SetAttr(result, state->keys, value) == -1)
4352 goto failed;
4353 44 Py_DECREF(value);
4354 44 value = ast2obj_list(state, (asdl_seq*)o->v.Dict.values, ast2obj_expr);
4355
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 if (!value) goto failed;
4356
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 44 times.
44 if (PyObject_SetAttr(result, state->values, value) == -1)
4357 goto failed;
4358 44 Py_DECREF(value);
4359 44 break;
4360 case Set_kind:
4361 tp = (PyTypeObject *)state->Set_type;
4362 result = PyType_GenericNew(tp, NULL, NULL);
4363 if (!result) goto failed;
4364 value = ast2obj_list(state, (asdl_seq*)o->v.Set.elts, ast2obj_expr);
4365 if (!value) goto failed;
4366 if (PyObject_SetAttr(result, state->elts, value) == -1)
4367 goto failed;
4368 Py_DECREF(value);
4369 break;
4370 12 case ListComp_kind:
4371 12 tp = (PyTypeObject *)state->ListComp_type;
4372 12 result = PyType_GenericNew(tp, NULL, NULL);
4373
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if (!result) goto failed;
4374 12 value = ast2obj_expr(state, o->v.ListComp.elt);
4375
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if (!value) goto failed;
4376
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
12 if (PyObject_SetAttr(result, state->elt, value) == -1)
4377 goto failed;
4378 12 Py_DECREF(value);
4379 12 value = ast2obj_list(state, (asdl_seq*)o->v.ListComp.generators,
4380 ast2obj_comprehension);
4381
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if (!value) goto failed;
4382
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
12 if (PyObject_SetAttr(result, state->generators, value) == -1)
4383 goto failed;
4384 12 Py_DECREF(value);
4385 12 break;
4386 case SetComp_kind:
4387 tp = (PyTypeObject *)state->SetComp_type;
4388 result = PyType_GenericNew(tp, NULL, NULL);
4389 if (!result) goto failed;
4390 value = ast2obj_expr(state, o->v.SetComp.elt);
4391 if (!value) goto failed;
4392 if (PyObject_SetAttr(result, state->elt, value) == -1)
4393 goto failed;
4394 Py_DECREF(value);
4395 value = ast2obj_list(state, (asdl_seq*)o->v.SetComp.generators,
4396 ast2obj_comprehension);
4397 if (!value) goto failed;
4398 if (PyObject_SetAttr(result, state->generators, value) == -1)
4399 goto failed;
4400 Py_DECREF(value);
4401 break;
4402 case DictComp_kind:
4403 tp = (PyTypeObject *)state->DictComp_type;
4404 result = PyType_GenericNew(tp, NULL, NULL);
4405 if (!result) goto failed;
4406 value = ast2obj_expr(state, o->v.DictComp.key);
4407 if (!value) goto failed;
4408 if (PyObject_SetAttr(result, state->key, value) == -1)
4409 goto failed;
4410 Py_DECREF(value);
4411 value = ast2obj_expr(state, o->v.DictComp.value);
4412 if (!value) goto failed;
4413 if (PyObject_SetAttr(result, state->value, value) == -1)
4414 goto failed;
4415 Py_DECREF(value);
4416 value = ast2obj_list(state, (asdl_seq*)o->v.DictComp.generators,
4417 ast2obj_comprehension);
4418 if (!value) goto failed;
4419 if (PyObject_SetAttr(result, state->generators, value) == -1)
4420 goto failed;
4421 Py_DECREF(value);
4422 break;
4423 4 case GeneratorExp_kind:
4424 4 tp = (PyTypeObject *)state->GeneratorExp_type;
4425 4 result = PyType_GenericNew(tp, NULL, NULL);
4426
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!result) goto failed;
4427 4 value = ast2obj_expr(state, o->v.GeneratorExp.elt);
4428
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!value) goto failed;
4429
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 if (PyObject_SetAttr(result, state->elt, value) == -1)
4430 goto failed;
4431 4 Py_DECREF(value);
4432 4 value = ast2obj_list(state, (asdl_seq*)o->v.GeneratorExp.generators,
4433 ast2obj_comprehension);
4434
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!value) goto failed;
4435
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 if (PyObject_SetAttr(result, state->generators, value) == -1)
4436 goto failed;
4437 4 Py_DECREF(value);
4438 4 break;
4439 case Await_kind:
4440 tp = (PyTypeObject *)state->Await_type;
4441 result = PyType_GenericNew(tp, NULL, NULL);
4442 if (!result) goto failed;
4443 value = ast2obj_expr(state, o->v.Await.value);
4444 if (!value) goto failed;
4445 if (PyObject_SetAttr(result, state->value, value) == -1)
4446 goto failed;
4447 Py_DECREF(value);
4448 break;
4449 case Yield_kind:
4450 tp = (PyTypeObject *)state->Yield_type;
4451 result = PyType_GenericNew(tp, NULL, NULL);
4452 if (!result) goto failed;
4453 value = ast2obj_expr(state, o->v.Yield.value);
4454 if (!value) goto failed;
4455 if (PyObject_SetAttr(result, state->value, value) == -1)
4456 goto failed;
4457 Py_DECREF(value);
4458 break;
4459 case YieldFrom_kind:
4460 tp = (PyTypeObject *)state->YieldFrom_type;
4461 result = PyType_GenericNew(tp, NULL, NULL);
4462 if (!result) goto failed;
4463 value = ast2obj_expr(state, o->v.YieldFrom.value);
4464 if (!value) goto failed;
4465 if (PyObject_SetAttr(result, state->value, value) == -1)
4466 goto failed;
4467 Py_DECREF(value);
4468 break;
4469 734 case Compare_kind:
4470 734 tp = (PyTypeObject *)state->Compare_type;
4471 734 result = PyType_GenericNew(tp, NULL, NULL);
4472
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 734 times.
734 if (!result) goto failed;
4473 734 value = ast2obj_expr(state, o->v.Compare.left);
4474
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 734 times.
734 if (!value) goto failed;
4475
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 734 times.
734 if (PyObject_SetAttr(result, state->left, value) == -1)
4476 goto failed;
4477 734 Py_DECREF(value);
4478 {
4479
1/2
✓ Branch 0 taken 734 times.
✗ Branch 1 not taken.
734 Py_ssize_t i, n = asdl_seq_LEN(o->v.Compare.ops);
4480 734 value = PyList_New(n);
4481
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 734 times.
734 if (!value) goto failed;
4482
2/2
✓ Branch 0 taken 734 times.
✓ Branch 1 taken 734 times.
1468 for(i = 0; i < n; i++)
4483 734 PyList_SET_ITEM(value, i, ast2obj_cmpop(state, (cmpop_ty)asdl_seq_GET(o->v.Compare.ops, i)));
4484 }
4485
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 734 times.
734 if (!value) goto failed;
4486
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 734 times.
734 if (PyObject_SetAttr(result, state->ops, value) == -1)
4487 goto failed;
4488 734 Py_DECREF(value);
4489 734 value = ast2obj_list(state, (asdl_seq*)o->v.Compare.comparators,
4490 ast2obj_expr);
4491
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 734 times.
734 if (!value) goto failed;
4492
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 734 times.
734 if (PyObject_SetAttr(result, state->comparators, value) == -1)
4493 goto failed;
4494 734 Py_DECREF(value);
4495 734 break;
4496 2390 case Call_kind:
4497 2390 tp = (PyTypeObject *)state->Call_type;
4498 2390 result = PyType_GenericNew(tp, NULL, NULL);
4499
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2390 times.
2390 if (!result) goto failed;
4500 2390 value = ast2obj_expr(state, o->v.Call.func);
4501
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2390 times.
2390 if (!value) goto failed;
4502
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 2390 times.
2390 if (PyObject_SetAttr(result, state->func, value) == -1)
4503 goto failed;
4504 2390 Py_DECREF(value);
4505 2390 value = ast2obj_list(state, (asdl_seq*)o->v.Call.args, ast2obj_expr);
4506
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2390 times.
2390 if (!value) goto failed;
4507
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 2390 times.
2390 if (PyObject_SetAttr(result, state->args, value) == -1)
4508 goto failed;
4509 2390 Py_DECREF(value);
4510 2390 value = ast2obj_list(state, (asdl_seq*)o->v.Call.keywords,
4511 ast2obj_keyword);
4512
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2390 times.
2390 if (!value) goto failed;
4513
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 2390 times.
2390 if (PyObject_SetAttr(result, state->keywords, value) == -1)
4514 goto failed;
4515 2390 Py_DECREF(value);
4516 2390 break;
4517 16 case FormattedValue_kind:
4518 16 tp = (PyTypeObject *)state->FormattedValue_type;
4519 16 result = PyType_GenericNew(tp, NULL, NULL);
4520
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if (!result) goto failed;
4521 16 value = ast2obj_expr(state, o->v.FormattedValue.value);
4522
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if (!value) goto failed;
4523
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
16 if (PyObject_SetAttr(result, state->value, value) == -1)
4524 goto failed;
4525 16 Py_DECREF(value);
4526 16 value = ast2obj_int(state, o->v.FormattedValue.conversion);
4527
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if (!value) goto failed;
4528
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
16 if (PyObject_SetAttr(result, state->conversion, value) == -1)
4529 goto failed;
4530 16 Py_DECREF(value);
4531 16 value = ast2obj_expr(state, o->v.FormattedValue.format_spec);
4532
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if (!value) goto failed;
4533
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
16 if (PyObject_SetAttr(result, state->format_spec, value) == -1)
4534 goto failed;
4535 16 Py_DECREF(value);
4536 16 break;
4537 8 case JoinedStr_kind:
4538 8 tp = (PyTypeObject *)state->JoinedStr_type;
4539 8 result = PyType_GenericNew(tp, NULL, NULL);
4540
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if (!result) goto failed;
4541 8 value = ast2obj_list(state, (asdl_seq*)o->v.JoinedStr.values,
4542 ast2obj_expr);
4543
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if (!value) goto failed;
4544
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
8 if (PyObject_SetAttr(result, state->values, value) == -1)
4545 goto failed;
4546 8 Py_DECREF(value);
4547 8 break;
4548 446440 case Constant_kind:
4549 446440 tp = (PyTypeObject *)state->Constant_type;
4550 446440 result = PyType_GenericNew(tp, NULL, NULL);
4551
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 446440 times.
446440 if (!result) goto failed;
4552 446440 value = ast2obj_constant(state, o->v.Constant.value);
4553
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 446440 times.
446440 if (!value) goto failed;
4554
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 446440 times.
446440 if (PyObject_SetAttr(result, state->value, value) == -1)
4555 goto failed;
4556 446440 Py_DECREF(value);
4557 446440 value = ast2obj_string(state, o->v.Constant.kind);
4558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 446440 times.
446440 if (!value) goto failed;
4559
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 446440 times.
446440 if (PyObject_SetAttr(result, state->kind, value) == -1)
4560 goto failed;
4561 446440 Py_DECREF(value);
4562 446440 break;
4563 1092 case Attribute_kind:
4564 1092 tp = (PyTypeObject *)state->Attribute_type;
4565 1092 result = PyType_GenericNew(tp, NULL, NULL);
4566
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1092 times.
1092 if (!result) goto failed;
4567 1092 value = ast2obj_expr(state, o->v.Attribute.value);
4568
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1092 times.
1092 if (!value) goto failed;
4569
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1092 times.
1092 if (PyObject_SetAttr(result, state->value, value) == -1)
4570 goto failed;
4571 1092 Py_DECREF(value);
4572 1092 value = ast2obj_identifier(state, o->v.Attribute.attr);
4573
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1092 times.
1092 if (!value) goto failed;
4574
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1092 times.
1092 if (PyObject_SetAttr(result, state->attr, value) == -1)
4575 goto failed;
4576 1092 Py_DECREF(value);
4577 1092 value = ast2obj_expr_context(state, o->v.Attribute.ctx);
4578
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1092 times.
1092 if (!value) goto failed;
4579
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1092 times.
1092 if (PyObject_SetAttr(result, state->ctx, value) == -1)
4580 goto failed;
4581 1092 Py_DECREF(value);
4582 1092 break;
4583 366 case Subscript_kind:
4584 366 tp = (PyTypeObject *)state->Subscript_type;
4585 366 result = PyType_GenericNew(tp, NULL, NULL);
4586
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 366 times.
366 if (!result) goto failed;
4587 366 value = ast2obj_expr(state, o->v.Subscript.value);
4588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 366 times.
366 if (!value) goto failed;
4589
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 366 times.
366 if (PyObject_SetAttr(result, state->value, value) == -1)
4590 goto failed;
4591 366 Py_DECREF(value);
4592 366 value = ast2obj_expr(state, o->v.Subscript.slice);
4593
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 366 times.
366 if (!value) goto failed;
4594
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 366 times.
366 if (PyObject_SetAttr(result, state->slice, value) == -1)
4595 goto failed;
4596 366 Py_DECREF(value);
4597 366 value = ast2obj_expr_context(state, o->v.Subscript.ctx);
4598
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 366 times.
366 if (!value) goto failed;
4599
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 366 times.
366 if (PyObject_SetAttr(result, state->ctx, value) == -1)
4600 goto failed;
4601 366 Py_DECREF(value);
4602 366 break;
4603 4 case Starred_kind:
4604 4 tp = (PyTypeObject *)state->Starred_type;
4605 4 result = PyType_GenericNew(tp, NULL, NULL);
4606
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!result) goto failed;
4607 4 value = ast2obj_expr(state, o->v.Starred.value);
4608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!value) goto failed;
4609
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 if (PyObject_SetAttr(result, state->value, value) == -1)
4610 goto failed;
4611 4 Py_DECREF(value);
4612 4 value = ast2obj_expr_context(state, o->v.Starred.ctx);
4613
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!value) goto failed;
4614
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 if (PyObject_SetAttr(result, state->ctx, value) == -1)
4615 goto failed;
4616 4 Py_DECREF(value);
4617 4 break;
4618 8994 case Name_kind:
4619 8994 tp = (PyTypeObject *)state->Name_type;
4620 8994 result = PyType_GenericNew(tp, NULL, NULL);
4621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8994 times.
8994 if (!result) goto failed;
4622 8994 value = ast2obj_identifier(state, o->v.Name.id);
4623
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8994 times.
8994 if (!value) goto failed;
4624
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 8994 times.
8994 if (PyObject_SetAttr(result, state->id, value) == -1)
4625 goto failed;
4626 8994 Py_DECREF(value);
4627 8994 value = ast2obj_expr_context(state, o->v.Name.ctx);
4628
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8994 times.
8994 if (!value) goto failed;
4629
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 8994 times.
8994 if (PyObject_SetAttr(result, state->ctx, value) == -1)
4630 goto failed;
4631 8994 Py_DECREF(value);
4632 8994 break;
4633 56 case List_kind:
4634 56 tp = (PyTypeObject *)state->List_type;
4635 56 result = PyType_GenericNew(tp, NULL, NULL);
4636
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 if (!result) goto failed;
4637 56 value = ast2obj_list(state, (asdl_seq*)o->v.List.elts, ast2obj_expr);
4638
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 if (!value) goto failed;
4639
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 56 times.
56 if (PyObject_SetAttr(result, state->elts, value) == -1)
4640 goto failed;
4641 56 Py_DECREF(value);
4642 56 value = ast2obj_expr_context(state, o->v.List.ctx);
4643
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 if (!value) goto failed;
4644
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 56 times.
56 if (PyObject_SetAttr(result, state->ctx, value) == -1)
4645 goto failed;
4646 56 Py_DECREF(value);
4647 56 break;
4648 249 case Tuple_kind:
4649 249 tp = (PyTypeObject *)state->Tuple_type;
4650 249 result = PyType_GenericNew(tp, NULL, NULL);
4651
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 249 times.
249 if (!result) goto failed;
4652 249 value = ast2obj_list(state, (asdl_seq*)o->v.Tuple.elts, ast2obj_expr);
4653
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 249 times.
249 if (!value) goto failed;
4654
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
249 if (PyObject_SetAttr(result, state->elts, value) == -1)
4655 goto failed;
4656 249 Py_DECREF(value);
4657 249 value = ast2obj_expr_context(state, o->v.Tuple.ctx);
4658
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 249 times.
249 if (!value) goto failed;
4659
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
249 if (PyObject_SetAttr(result, state->ctx, value) == -1)
4660 goto failed;
4661 249 Py_DECREF(value);
4662 249 break;
4663 case Slice_kind:
4664 tp = (PyTypeObject *)state->Slice_type;
4665 result = PyType_GenericNew(tp, NULL, NULL);
4666 if (!result) goto failed;
4667 value = ast2obj_expr(state, o->v.Slice.lower);
4668 if (!value) goto failed;
4669 if (PyObject_SetAttr(result, state->lower, value) == -1)
4670 goto failed;
4671 Py_DECREF(value);
4672 value = ast2obj_expr(state, o->v.Slice.upper);
4673 if (!value) goto failed;
4674 if (PyObject_SetAttr(result, state->upper, value) == -1)
4675 goto failed;
4676 Py_DECREF(value);
4677 value = ast2obj_expr(state, o->v.Slice.step);
4678 if (!value) goto failed;
4679 if (PyObject_SetAttr(result, state->step, value) == -1)
4680 goto failed;
4681 Py_DECREF(value);
4682 break;
4683 }
4684 460627 value = ast2obj_int(state, o->lineno);
4685
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460627 times.
460627 if (!value) goto failed;
4686
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 460627 times.
460627 if (PyObject_SetAttr(result, state->lineno, value) < 0)
4687 goto failed;
4688 460627 Py_DECREF(value);
4689 460627 value = ast2obj_int(state, o->col_offset);
4690
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460627 times.
460627 if (!value) goto failed;
4691
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 460627 times.
460627 if (PyObject_SetAttr(result, state->col_offset, value) < 0)
4692 goto failed;
4693 460627 Py_DECREF(value);
4694 460627 value = ast2obj_int(state, o->end_lineno);
4695
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460627 times.
460627 if (!value) goto failed;
4696
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 460627 times.
460627 if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
4697 goto failed;
4698 460627 Py_DECREF(value);
4699 460627 value = ast2obj_int(state, o->end_col_offset);
4700
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460627 times.
460627 if (!value) goto failed;
4701
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 460627 times.
460627 if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
4702 goto failed;
4703 460627 Py_DECREF(value);
4704 460627 return result;
4705 failed:
4706 Py_XDECREF(value);
4707 Py_XDECREF(result);
4708 return NULL;
4709 }
4710
4711 10761 PyObject* ast2obj_expr_context(struct ast_state *state, expr_context_ty o)
4712 {
4713
3/4
✓ Branch 0 taken 9103 times.
✓ Branch 1 taken 1588 times.
✓ Branch 2 taken 70 times.
✗ Branch 3 not taken.
10761 switch(o) {
4714 9103 case Load:
4715 9103 Py_INCREF(state->Load_singleton);
4716 9103 return state->Load_singleton;
4717 1588 case Store:
4718 1588 Py_INCREF(state->Store_singleton);
4719 1588 return state->Store_singleton;
4720 70 case Del:
4721 70 Py_INCREF(state->Del_singleton);
4722 70 return state->Del_singleton;
4723 }
4724 Py_UNREACHABLE();
4725 }
4726 78 PyObject* ast2obj_boolop(struct ast_state *state, boolop_ty o)
4727 {
4728
2/3
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 56 times.
✗ Branch 2 not taken.
78 switch(o) {
4729 22 case And:
4730 22 Py_INCREF(state->And_singleton);
4731 22 return state->And_singleton;
4732 56 case Or:
4733 56 Py_INCREF(state->Or_singleton);
4734 56 return state->Or_singleton;
4735 }
4736 Py_UNREACHABLE();
4737 }
4738 132 PyObject* ast2obj_operator(struct ast_state *state, operator_ty o)
4739 {
4740
3/14
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 44 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
132 switch(o) {
4741 66 case Add:
4742 66 Py_INCREF(state->Add_singleton);
4743 66 return state->Add_singleton;
4744 44 case Sub:
4745 44 Py_INCREF(state->Sub_singleton);
4746 44 return state->Sub_singleton;
4747 case Mult:
4748 Py_INCREF(state->Mult_singleton);
4749 return state->Mult_singleton;
4750 case MatMult:
4751 Py_INCREF(state->MatMult_singleton);
4752 return state->MatMult_singleton;
4753 case Div:
4754 Py_INCREF(state->Div_singleton);
4755 return state->Div_singleton;
4756 22 case Mod:
4757 22 Py_INCREF(state->Mod_singleton);
4758 22 return state->Mod_singleton;
4759 case Pow:
4760 Py_INCREF(state->Pow_singleton);
4761 return state->Pow_singleton;
4762 case LShift:
4763 Py_INCREF(state->LShift_singleton);
4764 return state->LShift_singleton;
4765 case RShift:
4766 Py_INCREF(state->RShift_singleton);
4767 return state->RShift_singleton;
4768 case BitOr:
4769 Py_INCREF(state->BitOr_singleton);
4770 return state->BitOr_singleton;
4771 case BitXor:
4772 Py_INCREF(state->BitXor_singleton);
4773 return state->BitXor_singleton;
4774 case BitAnd:
4775 Py_INCREF(state->BitAnd_singleton);
4776 return state->BitAnd_singleton;
4777 case FloorDiv:
4778 Py_INCREF(state->FloorDiv_singleton);
4779 return state->FloorDiv_singleton;
4780 }
4781 Py_UNREACHABLE();
4782 }
4783 8 PyObject* ast2obj_unaryop(struct ast_state *state, unaryop_ty o)
4784 {
4785
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
8 switch(o) {
4786 case Invert:
4787 Py_INCREF(state->Invert_singleton);
4788 return state->Invert_singleton;
4789 case Not:
4790 Py_INCREF(state->Not_singleton);
4791 return state->Not_singleton;
4792 case UAdd:
4793 Py_INCREF(state->UAdd_singleton);
4794 return state->UAdd_singleton;
4795 8 case USub:
4796 8 Py_INCREF(state->USub_singleton);
4797 8 return state->USub_singleton;
4798 }
4799 Py_UNREACHABLE();
4800 }
4801 734 PyObject* ast2obj_cmpop(struct ast_state *state, cmpop_ty o)
4802 {
4803
5/11
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 44 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 378 times.
✓ Branch 7 taken 180 times.
✓ Branch 8 taken 88 times.
✓ Branch 9 taken 44 times.
✗ Branch 10 not taken.
734 switch(o) {
4804 case Eq:
4805 Py_INCREF(state->Eq_singleton);
4806 return state->Eq_singleton;
4807 case NotEq:
4808 Py_INCREF(state->NotEq_singleton);
4809 return state->NotEq_singleton;
4810 case Lt:
4811 Py_INCREF(state->Lt_singleton);
4812 return state->Lt_singleton;
4813 case LtE:
4814 Py_INCREF(state->LtE_singleton);
4815 return state->LtE_singleton;
4816 44 case Gt:
4817 44 Py_INCREF(state->Gt_singleton);
4818 44 return state->Gt_singleton;
4819 case GtE:
4820 Py_INCREF(state->GtE_singleton);
4821 return state->GtE_singleton;
4822 378 case Is:
4823 378 Py_INCREF(state->Is_singleton);
4824 378 return state->Is_singleton;
4825 180 case IsNot:
4826 180 Py_INCREF(state->IsNot_singleton);
4827 180 return state->IsNot_singleton;
4828 88 case In:
4829 88 Py_INCREF(state->In_singleton);
4830 88 return state->In_singleton;
4831 44 case NotIn:
4832 44 Py_INCREF(state->NotIn_singleton);
4833 44 return state->NotIn_singleton;
4834 }
4835 Py_UNREACHABLE();
4836 }
4837 PyObject*
4838 16 ast2obj_comprehension(struct ast_state *state, void* _o)
4839 {
4840 16 comprehension_ty o = (comprehension_ty)_o;
4841 16 PyObject *result = NULL, *value = NULL;
4842 PyTypeObject *tp;
4843
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if (!o) {
4844 Py_RETURN_NONE;
4845 }
4846 16 tp = (PyTypeObject *)state->comprehension_type;
4847 16 result = PyType_GenericNew(tp, NULL, NULL);
4848
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if (!result) return NULL;
4849 16 value = ast2obj_expr(state, o->target);
4850
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if (!value) goto failed;
4851
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
16 if (PyObject_SetAttr(result, state->target, value) == -1)
4852 goto failed;
4853 16 Py_DECREF(value);
4854 16 value = ast2obj_expr(state, o->iter);
4855
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if (!value) goto failed;
4856
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
16 if (PyObject_SetAttr(result, state->iter, value) == -1)
4857 goto failed;
4858 16 Py_DECREF(value);
4859 16 value = ast2obj_list(state, (asdl_seq*)o->ifs, ast2obj_expr);
4860
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if (!value) goto failed;
4861
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
16 if (PyObject_SetAttr(result, state->ifs, value) == -1)
4862 goto failed;
4863 16 Py_DECREF(value);
4864 16 value = ast2obj_int(state, o->is_async);
4865
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if (!value) goto failed;
4866
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
16 if (PyObject_SetAttr(result, state->is_async, value) == -1)
4867 goto failed;
4868 16 Py_DECREF(value);
4869 16 return result;
4870 failed:
4871 Py_XDECREF(value);
4872 Py_XDECREF(result);
4873 return NULL;
4874 }
4875
4876 PyObject*
4877 70 ast2obj_excepthandler(struct ast_state *state, void* _o)
4878 {
4879 70 excepthandler_ty o = (excepthandler_ty)_o;
4880 70 PyObject *result = NULL, *value = NULL;
4881 PyTypeObject *tp;
4882
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 if (!o) {
4883 Py_RETURN_NONE;
4884 }
4885
1/2
✓ Branch 0 taken 70 times.
✗ Branch 1 not taken.
70 switch (o->kind) {
4886 70 case ExceptHandler_kind:
4887 70 tp = (PyTypeObject *)state->ExceptHandler_type;
4888 70 result = PyType_GenericNew(tp, NULL, NULL);
4889
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 if (!result) goto failed;
4890 70 value = ast2obj_expr(state, o->v.ExceptHandler.type);
4891
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 if (!value) goto failed;
4892
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 70 times.
70 if (PyObject_SetAttr(result, state->type, value) == -1)
4893 goto failed;
4894 70 Py_DECREF(value);
4895 70 value = ast2obj_identifier(state, o->v.ExceptHandler.name);
4896
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 if (!value) goto failed;
4897
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 70 times.
70 if (PyObject_SetAttr(result, state->name, value) == -1)
4898 goto failed;
4899 70 Py_DECREF(value);
4900 70 value = ast2obj_list(state, (asdl_seq*)o->v.ExceptHandler.body,
4901 ast2obj_stmt);
4902
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 if (!value) goto failed;
4903
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 70 times.
70 if (PyObject_SetAttr(result, state->body, value) == -1)
4904 goto failed;
4905 70 Py_DECREF(value);
4906 70 break;
4907 }
4908 70 value = ast2obj_int(state, o->lineno);
4909
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 if (!value) goto failed;
4910
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 70 times.
70 if (PyObject_SetAttr(result, state->lineno, value) < 0)
4911 goto failed;
4912 70 Py_DECREF(value);
4913 70 value = ast2obj_int(state, o->col_offset);
4914
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 if (!value) goto failed;
4915
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 70 times.
70 if (PyObject_SetAttr(result, state->col_offset, value) < 0)
4916 goto failed;
4917 70 Py_DECREF(value);
4918 70 value = ast2obj_int(state, o->end_lineno);
4919
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 if (!value) goto failed;
4920
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 70 times.
70 if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
4921 goto failed;
4922 70 Py_DECREF(value);
4923 70 value = ast2obj_int(state, o->end_col_offset);
4924
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 if (!value) goto failed;
4925
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 70 times.
70 if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
4926 goto failed;
4927 70 Py_DECREF(value);
4928 70 return result;
4929 failed:
4930 Py_XDECREF(value);
4931 Py_XDECREF(result);
4932 return NULL;
4933 }
4934
4935 PyObject*
4936 340 ast2obj_arguments(struct ast_state *state, void* _o)
4937 {
4938 340 arguments_ty o = (arguments_ty)_o;
4939 340 PyObject *result = NULL, *value = NULL;
4940 PyTypeObject *tp;
4941
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 340 times.
340 if (!o) {
4942 Py_RETURN_NONE;
4943 }
4944 340 tp = (PyTypeObject *)state->arguments_type;
4945 340 result = PyType_GenericNew(tp, NULL, NULL);
4946
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 340 times.
340 if (!result) return NULL;
4947 340 value = ast2obj_list(state, (asdl_seq*)o->posonlyargs, ast2obj_arg);
4948
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 340 times.
340 if (!value) goto failed;
4949
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 340 times.
340 if (PyObject_SetAttr(result, state->posonlyargs, value) == -1)
4950 goto failed;
4951 340 Py_DECREF(value);
4952 340 value = ast2obj_list(state, (asdl_seq*)o->args, ast2obj_arg);
4953
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 340 times.
340 if (!value) goto failed;
4954
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 340 times.
340 if (PyObject_SetAttr(result, state->args, value) == -1)
4955 goto failed;
4956 340 Py_DECREF(value);
4957 340 value = ast2obj_arg(state, o->vararg);
4958
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 340 times.
340 if (!value) goto failed;
4959
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 340 times.
340 if (PyObject_SetAttr(result, state->vararg, value) == -1)
4960 goto failed;
4961 340 Py_DECREF(value);
4962 340 value = ast2obj_list(state, (asdl_seq*)o->kwonlyargs, ast2obj_arg);
4963
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 340 times.
340 if (!value) goto failed;
4964
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 340 times.
340 if (PyObject_SetAttr(result, state->kwonlyargs, value) == -1)
4965 goto failed;
4966 340 Py_DECREF(value);
4967 340 value = ast2obj_list(state, (asdl_seq*)o->kw_defaults, ast2obj_expr);
4968
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 340 times.
340 if (!value) goto failed;
4969
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 340 times.
340 if (PyObject_SetAttr(result, state->kw_defaults, value) == -1)
4970 goto failed;
4971 340 Py_DECREF(value);
4972 340 value = ast2obj_arg(state, o->kwarg);
4973
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 340 times.
340 if (!value) goto failed;
4974
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 340 times.
340 if (PyObject_SetAttr(result, state->kwarg, value) == -1)
4975 goto failed;
4976 340 Py_DECREF(value);
4977 340 value = ast2obj_list(state, (asdl_seq*)o->defaults, ast2obj_expr);
4978
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 340 times.
340 if (!value) goto failed;
4979
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 340 times.
340 if (PyObject_SetAttr(result, state->defaults, value) == -1)
4980 goto failed;
4981 340 Py_DECREF(value);
4982 340 return result;
4983 failed:
4984 Py_XDECREF(value);
4985 Py_XDECREF(result);
4986 return NULL;
4987 }
4988
4989 PyObject*
4990 1098 ast2obj_arg(struct ast_state *state, void* _o)
4991 {
4992 1098 arg_ty o = (arg_ty)_o;
4993 1098 PyObject *result = NULL, *value = NULL;
4994 PyTypeObject *tp;
4995
2/2
✓ Branch 0 taken 664 times.
✓ Branch 1 taken 434 times.
1098 if (!o) {
4996 664 Py_RETURN_NONE;
4997 }
4998 434 tp = (PyTypeObject *)state->arg_type;
4999 434 result = PyType_GenericNew(tp, NULL, NULL);
5000
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 434 times.
434 if (!result) return NULL;
5001 434 value = ast2obj_identifier(state, o->arg);
5002
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 434 times.
434 if (!value) goto failed;
5003
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 434 times.
434 if (PyObject_SetAttr(result, state->arg, value) == -1)
5004 goto failed;
5005 434 Py_DECREF(value);
5006 434 value = ast2obj_expr(state, o->annotation);
5007
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 434 times.
434 if (!value) goto failed;
5008
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 434 times.
434 if (PyObject_SetAttr(result, state->annotation, value) == -1)
5009 goto failed;
5010 434 Py_DECREF(value);
5011 434 value = ast2obj_string(state, o->type_comment);
5012
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 434 times.
434 if (!value) goto failed;
5013
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 434 times.
434 if (PyObject_SetAttr(result, state->type_comment, value) == -1)
5014 goto failed;
5015 434 Py_DECREF(value);
5016 434 value = ast2obj_int(state, o->lineno);
5017
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 434 times.
434 if (!value) goto failed;
5018
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 434 times.
434 if (PyObject_SetAttr(result, state->lineno, value) < 0)
5019 goto failed;
5020 434 Py_DECREF(value);
5021 434 value = ast2obj_int(state, o->col_offset);
5022
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 434 times.
434 if (!value) goto failed;
5023
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 434 times.
434 if (PyObject_SetAttr(result, state->col_offset, value) < 0)
5024 goto failed;
5025 434 Py_DECREF(value);
5026 434 value = ast2obj_int(state, o->end_lineno);
5027
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 434 times.
434 if (!value) goto failed;
5028
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 434 times.
434 if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
5029 goto failed;
5030 434 Py_DECREF(value);
5031 434 value = ast2obj_int(state, o->end_col_offset);
5032
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 434 times.
434 if (!value) goto failed;
5033
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 434 times.
434 if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
5034 goto failed;
5035 434 Py_DECREF(value);
5036 434 return result;
5037 failed:
5038 Py_XDECREF(value);
5039 Py_XDECREF(result);
5040 return NULL;
5041 }
5042
5043 PyObject*
5044 4 ast2obj_keyword(struct ast_state *state, void* _o)
5045 {
5046 4 keyword_ty o = (keyword_ty)_o;
5047 4 PyObject *result = NULL, *value = NULL;
5048 PyTypeObject *tp;
5049
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!o) {
5050 Py_RETURN_NONE;
5051 }
5052 4 tp = (PyTypeObject *)state->keyword_type;
5053 4 result = PyType_GenericNew(tp, NULL, NULL);
5054
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!result) return NULL;
5055 4 value = ast2obj_identifier(state, o->arg);
5056
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!value) goto failed;
5057
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 if (PyObject_SetAttr(result, state->arg, value) == -1)
5058 goto failed;
5059 4 Py_DECREF(value);
5060 4 value = ast2obj_expr(state, o->value);
5061
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!value) goto failed;
5062
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 if (PyObject_SetAttr(result, state->value, value) == -1)
5063 goto failed;
5064 4 Py_DECREF(value);
5065 4 value = ast2obj_int(state, o->lineno);
5066
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!value) goto failed;
5067
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 if (PyObject_SetAttr(result, state->lineno, value) < 0)
5068 goto failed;
5069 4 Py_DECREF(value);
5070 4 value = ast2obj_int(state, o->col_offset);
5071
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!value) goto failed;
5072
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 if (PyObject_SetAttr(result, state->col_offset, value) < 0)
5073 goto failed;
5074 4 Py_DECREF(value);
5075 4 value = ast2obj_int(state, o->end_lineno);
5076
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!value) goto failed;
5077
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
5078 goto failed;
5079 4 Py_DECREF(value);
5080 4 value = ast2obj_int(state, o->end_col_offset);
5081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!value) goto failed;
5082
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
5083 goto failed;
5084 4 Py_DECREF(value);
5085 4 return result;
5086 failed:
5087 Py_XDECREF(value);
5088 Py_XDECREF(result);
5089 return NULL;
5090 }
5091
5092 PyObject*
5093 144 ast2obj_alias(struct ast_state *state, void* _o)
5094 {
5095 144 alias_ty o = (alias_ty)_o;
5096 144 PyObject *result = NULL, *value = NULL;
5097 PyTypeObject *tp;
5098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if (!o) {
5099 Py_RETURN_NONE;
5100 }
5101 144 tp = (PyTypeObject *)state->alias_type;
5102 144 result = PyType_GenericNew(tp, NULL, NULL);
5103
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if (!result) return NULL;
5104 144 value = ast2obj_identifier(state, o->name);
5105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if (!value) goto failed;
5106
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 144 times.
144 if (PyObject_SetAttr(result, state->name, value) == -1)
5107 goto failed;
5108 144 Py_DECREF(value);
5109 144 value = ast2obj_identifier(state, o->asname);
5110
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if (!value) goto failed;
5111
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 144 times.
144 if (PyObject_SetAttr(result, state->asname, value) == -1)
5112 goto failed;
5113 144 Py_DECREF(value);
5114 144 value = ast2obj_int(state, o->lineno);
5115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if (!value) goto failed;
5116
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 144 times.
144 if (PyObject_SetAttr(result, state->lineno, value) < 0)
5117 goto failed;
5118 144 Py_DECREF(value);
5119 144 value = ast2obj_int(state, o->col_offset);
5120
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if (!value) goto failed;
5121
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 144 times.
144 if (PyObject_SetAttr(result, state->col_offset, value) < 0)
5122 goto failed;
5123 144 Py_DECREF(value);
5124 144 value = ast2obj_int(state, o->end_lineno);
5125
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if (!value) goto failed;
5126
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 144 times.
144 if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
5127 goto failed;
5128 144 Py_DECREF(value);
5129 144 value = ast2obj_int(state, o->end_col_offset);
5130
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if (!value) goto failed;
5131
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 144 times.
144 if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
5132 goto failed;
5133 144 Py_DECREF(value);
5134 144 return result;
5135 failed:
5136 Py_XDECREF(value);
5137 Py_XDECREF(result);
5138 return NULL;
5139 }
5140
5141 PyObject*
5142 ast2obj_withitem(struct ast_state *state, void* _o)
5143 {
5144 withitem_ty o = (withitem_ty)_o;
5145 PyObject *result = NULL, *value = NULL;
5146 PyTypeObject *tp;
5147 if (!o) {
5148 Py_RETURN_NONE;
5149 }
5150 tp = (PyTypeObject *)state->withitem_type;
5151 result = PyType_GenericNew(tp, NULL, NULL);
5152 if (!result) return NULL;
5153 value = ast2obj_expr(state, o->context_expr);
5154 if (!value) goto failed;
5155 if (PyObject_SetAttr(result, state->context_expr, value) == -1)
5156 goto failed;
5157 Py_DECREF(value);
5158 value = ast2obj_expr(state, o->optional_vars);
5159 if (!value) goto failed;
5160 if (PyObject_SetAttr(result, state->optional_vars, value) == -1)
5161 goto failed;
5162 Py_DECREF(value);
5163 return result;
5164 failed:
5165 Py_XDECREF(value);
5166 Py_XDECREF(result);
5167 return NULL;
5168 }
5169
5170 PyObject*
5171 ast2obj_match_case(struct ast_state *state, void* _o)
5172 {
5173 match_case_ty o = (match_case_ty)_o;
5174 PyObject *result = NULL, *value = NULL;
5175 PyTypeObject *tp;
5176 if (!o) {
5177 Py_RETURN_NONE;
5178 }
5179 tp = (PyTypeObject *)state->match_case_type;
5180 result = PyType_GenericNew(tp, NULL, NULL);
5181 if (!result) return NULL;
5182 value = ast2obj_pattern(state, o->pattern);
5183 if (!value) goto failed;
5184 if (PyObject_SetAttr(result, state->pattern, value) == -1)
5185 goto failed;
5186 Py_DECREF(value);
5187 value = ast2obj_expr(state, o->guard);
5188 if (!value) goto failed;
5189 if (PyObject_SetAttr(result, state->guard, value) == -1)
5190 goto failed;
5191 Py_DECREF(value);
5192 value = ast2obj_list(state, (asdl_seq*)o->body, ast2obj_stmt);
5193 if (!value) goto failed;
5194 if (PyObject_SetAttr(result, state->body, value) == -1)
5195 goto failed;
5196 Py_DECREF(value);
5197 return result;
5198 failed:
5199 Py_XDECREF(value);
5200 Py_XDECREF(result);
5201 return NULL;
5202 }
5203
5204 PyObject*
5205 ast2obj_pattern(struct ast_state *state, void* _o)
5206 {
5207 pattern_ty o = (pattern_ty)_o;
5208 PyObject *result = NULL, *value = NULL;
5209 PyTypeObject *tp;
5210 if (!o) {
5211 Py_RETURN_NONE;
5212 }
5213 switch (o->kind) {
5214 case MatchValue_kind:
5215 tp = (PyTypeObject *)state->MatchValue_type;
5216 result = PyType_GenericNew(tp, NULL, NULL);
5217 if (!result) goto failed;
5218 value = ast2obj_expr(state, o->v.MatchValue.value);
5219 if (!value) goto failed;
5220 if (PyObject_SetAttr(result, state->value, value) == -1)
5221 goto failed;
5222 Py_DECREF(value);
5223 break;
5224 case MatchSingleton_kind:
5225 tp = (PyTypeObject *)state->MatchSingleton_type;
5226 result = PyType_GenericNew(tp, NULL, NULL);
5227 if (!result) goto failed;
5228 value = ast2obj_constant(state, o->v.MatchSingleton.value);
5229 if (!value) goto failed;
5230 if (PyObject_SetAttr(result, state->value, value) == -1)
5231 goto failed;
5232 Py_DECREF(value);
5233 break;
5234 case MatchSequence_kind:
5235 tp = (PyTypeObject *)state->MatchSequence_type;
5236 result = PyType_GenericNew(tp, NULL, NULL);
5237 if (!result) goto failed;
5238 value = ast2obj_list(state, (asdl_seq*)o->v.MatchSequence.patterns,
5239 ast2obj_pattern);
5240 if (!value) goto failed;
5241 if (PyObject_SetAttr(result, state->patterns, value) == -1)
5242 goto failed;
5243 Py_DECREF(value);
5244 break;
5245 case MatchMapping_kind:
5246 tp = (PyTypeObject *)state->MatchMapping_type;
5247 result = PyType_GenericNew(tp, NULL, NULL);
5248 if (!result) goto failed;
5249 value = ast2obj_list(state, (asdl_seq*)o->v.MatchMapping.keys,
5250 ast2obj_expr);
5251 if (!value) goto failed;
5252 if (PyObject_SetAttr(result, state->keys, value) == -1)
5253 goto failed;
5254 Py_DECREF(value);
5255 value = ast2obj_list(state, (asdl_seq*)o->v.MatchMapping.patterns,
5256 ast2obj_pattern);
5257 if (!value) goto failed;
5258 if (PyObject_SetAttr(result, state->patterns, value) == -1)
5259 goto failed;
5260 Py_DECREF(value);
5261 value = ast2obj_identifier(state, o->v.MatchMapping.rest);
5262 if (!value) goto failed;
5263 if (PyObject_SetAttr(result, state->rest, value) == -1)
5264 goto failed;
5265 Py_DECREF(value);
5266 break;
5267 case MatchClass_kind:
5268 tp = (PyTypeObject *)state->MatchClass_type;
5269 result = PyType_GenericNew(tp, NULL, NULL);
5270 if (!result) goto failed;
5271 value = ast2obj_expr(state, o->v.MatchClass.cls);
5272 if (!value) goto failed;
5273 if (PyObject_SetAttr(result, state->cls, value) == -1)
5274 goto failed;
5275 Py_DECREF(value);
5276 value = ast2obj_list(state, (asdl_seq*)o->v.MatchClass.patterns,
5277 ast2obj_pattern);
5278 if (!value) goto failed;
5279 if (PyObject_SetAttr(result, state->patterns, value) == -1)
5280 goto failed;
5281 Py_DECREF(value);
5282 value = ast2obj_list(state, (asdl_seq*)o->v.MatchClass.kwd_attrs,
5283 ast2obj_identifier);
5284 if (!value) goto failed;
5285 if (PyObject_SetAttr(result, state->kwd_attrs, value) == -1)
5286 goto failed;
5287 Py_DECREF(value);
5288 value = ast2obj_list(state, (asdl_seq*)o->v.MatchClass.kwd_patterns,
5289 ast2obj_pattern);
5290 if (!value) goto failed;
5291 if (PyObject_SetAttr(result, state->kwd_patterns, value) == -1)
5292 goto failed;
5293 Py_DECREF(value);
5294 break;
5295 case MatchStar_kind:
5296 tp = (PyTypeObject *)state->MatchStar_type;
5297 result = PyType_GenericNew(tp, NULL, NULL);
5298 if (!result) goto failed;
5299 value = ast2obj_identifier(state, o->v.MatchStar.name);
5300 if (!value) goto failed;
5301 if (PyObject_SetAttr(result, state->name, value) == -1)
5302 goto failed;
5303 Py_DECREF(value);
5304 break;
5305 case MatchAs_kind:
5306 tp = (PyTypeObject *)state->MatchAs_type;
5307 result = PyType_GenericNew(tp, NULL, NULL);
5308 if (!result) goto failed;
5309 value = ast2obj_pattern(state, o->v.MatchAs.pattern);
5310 if (!value) goto failed;
5311 if (PyObject_SetAttr(result, state->pattern, value) == -1)
5312 goto failed;
5313 Py_DECREF(value);
5314 value = ast2obj_identifier(state, o->v.MatchAs.name);
5315 if (!value) goto failed;
5316 if (PyObject_SetAttr(result, state->name, value) == -1)
5317 goto failed;
5318 Py_DECREF(value);
5319 break;
5320 case MatchOr_kind:
5321 tp = (PyTypeObject *)state->MatchOr_type;
5322 result = PyType_GenericNew(tp, NULL, NULL);
5323 if (!result) goto failed;
5324 value = ast2obj_list(state, (asdl_seq*)o->v.MatchOr.patterns,
5325 ast2obj_pattern);
5326 if (!value) goto failed;
5327 if (PyObject_SetAttr(result, state->patterns, value) == -1)
5328 goto failed;
5329 Py_DECREF(value);
5330 break;
5331 }
5332 value = ast2obj_int(state, o->lineno);
5333 if (!value) goto failed;
5334 if (PyObject_SetAttr(result, state->lineno, value) < 0)
5335 goto failed;
5336 Py_DECREF(value);
5337 value = ast2obj_int(state, o->col_offset);
5338 if (!value) goto failed;
5339 if (PyObject_SetAttr(result, state->col_offset, value) < 0)
5340 goto failed;
5341 Py_DECREF(value);
5342 value = ast2obj_int(state, o->end_lineno);
5343 if (!value) goto failed;
5344 if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
5345 goto failed;
5346 Py_DECREF(value);
5347 value = ast2obj_int(state, o->end_col_offset);
5348 if (!value) goto failed;
5349 if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
5350 goto failed;
5351 Py_DECREF(value);
5352 return result;
5353 failed:
5354 Py_XDECREF(value);
5355 Py_XDECREF(result);
5356 return NULL;
5357 }
5358
5359 PyObject*
5360 ast2obj_type_ignore(struct ast_state *state, void* _o)
5361 {
5362 type_ignore_ty o = (type_ignore_ty)_o;
5363 PyObject *result = NULL, *value = NULL;
5364 PyTypeObject *tp;
5365 if (!o) {
5366 Py_RETURN_NONE;
5367 }
5368 switch (o->kind) {
5369 case TypeIgnore_kind:
5370 tp = (PyTypeObject *)state->TypeIgnore_type;
5371 result = PyType_GenericNew(tp, NULL, NULL);
5372 if (!result) goto failed;
5373 value = ast2obj_int(state, o->v.TypeIgnore.lineno);
5374 if (!value) goto failed;
5375 if (PyObject_SetAttr(result, state->lineno, value) == -1)
5376 goto failed;
5377 Py_DECREF(value);
5378 value = ast2obj_string(state, o->v.TypeIgnore.tag);
5379 if (!value) goto failed;
5380 if (PyObject_SetAttr(result, state->tag, value) == -1)
5381 goto failed;
5382 Py_DECREF(value);
5383 break;
5384 }
5385 return result;
5386 failed:
5387 Py_XDECREF(value);
5388 Py_XDECREF(result);
5389 return NULL;
5390 }
5391
5392
5393 int
5394 obj2ast_mod(struct ast_state *state, PyObject* obj, mod_ty* out, PyArena* arena)
5395 {
5396 int isinstance;
5397
5398 PyObject *tmp = NULL;
5399 PyObject *tp;
5400
5401 if (obj == Py_None) {
5402 *out = NULL;
5403 return 0;
5404 }
5405 tp = state->Module_type;
5406 isinstance = PyObject_IsInstance(obj, tp);
5407 if (isinstance == -1) {
5408 return 1;
5409 }
5410 if (isinstance) {
5411 asdl_stmt_seq* body;
5412 asdl_type_ignore_seq* type_ignores;
5413
5414 if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
5415 return 1;
5416 }
5417 if (tmp == NULL) {
5418 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Module");
5419 return 1;
5420 }
5421 else {
5422 int res;
5423 Py_ssize_t len;
5424 Py_ssize_t i;
5425 if (!PyList_Check(tmp)) {
5426 PyErr_Format(PyExc_TypeError, "Module field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
5427 goto failed;
5428 }
5429 len = PyList_GET_SIZE(tmp);
5430 body = _Py_asdl_stmt_seq_new(len, arena);
5431 if (body == NULL) goto failed;
5432 for (i = 0; i < len; i++) {
5433 stmt_ty val;
5434 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
5435 Py_INCREF(tmp2);
5436 if (_Py_EnterRecursiveCall(" while traversing 'Module' node")) {
5437 goto failed;
5438 }
5439 res = obj2ast_stmt(state, tmp2, &val, arena);
5440 _Py_LeaveRecursiveCall();
5441 Py_DECREF(tmp2);
5442 if (res != 0) goto failed;
5443 if (len != PyList_GET_SIZE(tmp)) {
5444 PyErr_SetString(PyExc_RuntimeError, "Module field \"body\" changed size during iteration");
5445 goto failed;
5446 }
5447 asdl_seq_SET(body, i, val);
5448 }
5449 Py_CLEAR(tmp);
5450 }
5451 if (_PyObject_LookupAttr(obj, state->type_ignores, &tmp) < 0) {
5452 return 1;
5453 }
5454 if (tmp == NULL) {
5455 PyErr_SetString(PyExc_TypeError, "required field \"type_ignores\" missing from Module");
5456 return 1;
5457 }
5458 else {
5459 int res;
5460 Py_ssize_t len;
5461 Py_ssize_t i;
5462 if (!PyList_Check(tmp)) {
5463 PyErr_Format(PyExc_TypeError, "Module field \"type_ignores\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
5464 goto failed;
5465 }
5466 len = PyList_GET_SIZE(tmp);
5467 type_ignores = _Py_asdl_type_ignore_seq_new(len, arena);
5468 if (type_ignores == NULL) goto failed;
5469 for (i = 0; i < len; i++) {
5470 type_ignore_ty val;
5471 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
5472 Py_INCREF(tmp2);
5473 if (_Py_EnterRecursiveCall(" while traversing 'Module' node")) {
5474 goto failed;
5475 }
5476 res = obj2ast_type_ignore(state, tmp2, &val, arena);
5477 _Py_LeaveRecursiveCall();
5478 Py_DECREF(tmp2);
5479 if (res != 0) goto failed;
5480 if (len != PyList_GET_SIZE(tmp)) {
5481 PyErr_SetString(PyExc_RuntimeError, "Module field \"type_ignores\" changed size during iteration");
5482 goto failed;
5483 }
5484 asdl_seq_SET(type_ignores, i, val);
5485 }
5486 Py_CLEAR(tmp);
5487 }
5488 *out = _PyAST_Module(body, type_ignores, arena);
5489 if (*out == NULL) goto failed;
5490 return 0;
5491 }
5492 tp = state->Interactive_type;
5493 isinstance = PyObject_IsInstance(obj, tp);
5494 if (isinstance == -1) {
5495 return 1;
5496 }
5497 if (isinstance) {
5498 asdl_stmt_seq* body;
5499
5500 if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
5501 return 1;
5502 }
5503 if (tmp == NULL) {
5504 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Interactive");
5505 return 1;
5506 }
5507 else {
5508 int res;
5509 Py_ssize_t len;
5510 Py_ssize_t i;
5511 if (!PyList_Check(tmp)) {
5512 PyErr_Format(PyExc_TypeError, "Interactive field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
5513 goto failed;
5514 }
5515 len = PyList_GET_SIZE(tmp);
5516 body = _Py_asdl_stmt_seq_new(len, arena);
5517 if (body == NULL) goto failed;
5518 for (i = 0; i < len; i++) {
5519 stmt_ty val;
5520 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
5521 Py_INCREF(tmp2);
5522 if (_Py_EnterRecursiveCall(" while traversing 'Interactive' node")) {
5523 goto failed;
5524 }
5525 res = obj2ast_stmt(state, tmp2, &val, arena);
5526 _Py_LeaveRecursiveCall();
5527 Py_DECREF(tmp2);
5528 if (res != 0) goto failed;
5529 if (len != PyList_GET_SIZE(tmp)) {
5530 PyErr_SetString(PyExc_RuntimeError, "Interactive field \"body\" changed size during iteration");
5531 goto failed;
5532 }
5533 asdl_seq_SET(body, i, val);
5534 }
5535 Py_CLEAR(tmp);
5536 }
5537 *out = _PyAST_Interactive(body, arena);
5538 if (*out == NULL) goto failed;
5539 return 0;
5540 }
5541 tp = state->Expression_type;
5542 isinstance = PyObject_IsInstance(obj, tp);
5543 if (isinstance == -1) {
5544 return 1;
5545 }
5546 if (isinstance) {
5547 expr_ty body;
5548
5549 if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
5550 return 1;
5551 }
5552 if (tmp == NULL) {
5553 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Expression");
5554 return 1;
5555 }
5556 else {
5557 int res;
5558 if (_Py_EnterRecursiveCall(" while traversing 'Expression' node")) {
5559 goto failed;
5560 }
5561 res = obj2ast_expr(state, tmp, &body, arena);
5562 _Py_LeaveRecursiveCall();
5563 if (res != 0) goto failed;
5564 Py_CLEAR(tmp);
5565 }
5566 *out = _PyAST_Expression(body, arena);
5567 if (*out == NULL) goto failed;
5568 return 0;
5569 }
5570 tp = state->FunctionType_type;
5571 isinstance = PyObject_IsInstance(obj, tp);
5572 if (isinstance == -1) {
5573 return 1;
5574 }
5575 if (isinstance) {
5576 asdl_expr_seq* argtypes;
5577 expr_ty returns;
5578
5579 if (_PyObject_LookupAttr(obj, state->argtypes, &tmp) < 0) {
5580 return 1;
5581 }
5582 if (tmp == NULL) {
5583 PyErr_SetString(PyExc_TypeError, "required field \"argtypes\" missing from FunctionType");
5584 return 1;
5585 }
5586 else {
5587 int res;
5588 Py_ssize_t len;
5589 Py_ssize_t i;
5590 if (!PyList_Check(tmp)) {
5591 PyErr_Format(PyExc_TypeError, "FunctionType field \"argtypes\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
5592 goto failed;
5593 }
5594 len = PyList_GET_SIZE(tmp);
5595 argtypes = _Py_asdl_expr_seq_new(len, arena);
5596 if (argtypes == NULL) goto failed;
5597 for (i = 0; i < len; i++) {
5598 expr_ty val;
5599 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
5600 Py_INCREF(tmp2);
5601 if (_Py_EnterRecursiveCall(" while traversing 'FunctionType' node")) {
5602 goto failed;
5603 }
5604 res = obj2ast_expr(state, tmp2, &val, arena);
5605 _Py_LeaveRecursiveCall();
5606 Py_DECREF(tmp2);
5607 if (res != 0) goto failed;
5608 if (len != PyList_GET_SIZE(tmp)) {
5609 PyErr_SetString(PyExc_RuntimeError, "FunctionType field \"argtypes\" changed size during iteration");
5610 goto failed;
5611 }
5612 asdl_seq_SET(argtypes, i, val);
5613 }
5614 Py_CLEAR(tmp);
5615 }
5616 if (_PyObject_LookupAttr(obj, state->returns, &tmp) < 0) {
5617 return 1;
5618 }
5619 if (tmp == NULL) {
5620 PyErr_SetString(PyExc_TypeError, "required field \"returns\" missing from FunctionType");
5621 return 1;
5622 }
5623 else {
5624 int res;
5625 if (_Py_EnterRecursiveCall(" while traversing 'FunctionType' node")) {
5626 goto failed;
5627 }
5628 res = obj2ast_expr(state, tmp, &returns, arena);
5629 _Py_LeaveRecursiveCall();
5630 if (res != 0) goto failed;
5631 Py_CLEAR(tmp);
5632 }
5633 *out = _PyAST_FunctionType(argtypes, returns, arena);
5634 if (*out == NULL) goto failed;
5635 return 0;
5636 }
5637
5638 PyErr_Format(PyExc_TypeError, "expected some sort of mod, but got %R", obj);
5639 failed:
5640 Py_XDECREF(tmp);
5641 return 1;
5642 }
5643
5644 int
5645 obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
5646 arena)
5647 {
5648 int isinstance;
5649
5650 PyObject *tmp = NULL;
5651 PyObject *tp;
5652 int lineno;
5653 int col_offset;
5654 int end_lineno;
5655 int end_col_offset;
5656
5657 if (obj == Py_None) {
5658 *out = NULL;
5659 return 0;
5660 }
5661 if (_PyObject_LookupAttr(obj, state->lineno, &tmp) < 0) {
5662 return 1;
5663 }
5664 if (tmp == NULL) {
5665 PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from stmt");
5666 return 1;
5667 }
5668 else {
5669 int res;
5670 if (_Py_EnterRecursiveCall(" while traversing 'stmt' node")) {
5671 goto failed;
5672 }
5673 res = obj2ast_int(state, tmp, &lineno, arena);
5674 _Py_LeaveRecursiveCall();
5675 if (res != 0) goto failed;
5676 Py_CLEAR(tmp);
5677 }
5678 if (_PyObject_LookupAttr(obj, state->col_offset, &tmp) < 0) {
5679 return 1;
5680 }
5681 if (tmp == NULL) {
5682 PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from stmt");
5683 return 1;
5684 }
5685 else {
5686 int res;
5687 if (_Py_EnterRecursiveCall(" while traversing 'stmt' node")) {
5688 goto failed;
5689 }
5690 res = obj2ast_int(state, tmp, &col_offset, arena);
5691 _Py_LeaveRecursiveCall();
5692 if (res != 0) goto failed;
5693 Py_CLEAR(tmp);
5694 }
5695 if (_PyObject_LookupAttr(obj, state->end_lineno, &tmp) < 0) {
5696 return 1;
5697 }
5698 if (tmp == NULL || tmp == Py_None) {
5699 Py_CLEAR(tmp);
5700 end_lineno = lineno;
5701 }
5702 else {
5703 int res;
5704 if (_Py_EnterRecursiveCall(" while traversing 'stmt' node")) {
5705 goto failed;
5706 }
5707 res = obj2ast_int(state, tmp, &end_lineno, arena);
5708 _Py_LeaveRecursiveCall();
5709 if (res != 0) goto failed;
5710 Py_CLEAR(tmp);
5711 }
5712 if (_PyObject_LookupAttr(obj, state->end_col_offset, &tmp) < 0) {
5713 return 1;
5714 }
5715 if (tmp == NULL || tmp == Py_None) {
5716 Py_CLEAR(tmp);
5717 end_col_offset = col_offset;
5718 }
5719 else {
5720 int res;
5721 if (_Py_EnterRecursiveCall(" while traversing 'stmt' node")) {
5722 goto failed;
5723 }
5724 res = obj2ast_int(state, tmp, &end_col_offset, arena);
5725 _Py_LeaveRecursiveCall();
5726 if (res != 0) goto failed;
5727 Py_CLEAR(tmp);
5728 }
5729 tp = state->FunctionDef_type;
5730 isinstance = PyObject_IsInstance(obj, tp);
5731 if (isinstance == -1) {
5732 return 1;
5733 }
5734 if (isinstance) {
5735 identifier name;
5736 arguments_ty args;
5737 asdl_stmt_seq* body;
5738 asdl_expr_seq* decorator_list;
5739 expr_ty returns;
5740 string type_comment;
5741
5742 if (_PyObject_LookupAttr(obj, state->name, &tmp) < 0) {
5743 return 1;
5744 }
5745 if (tmp == NULL) {
5746 PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from FunctionDef");
5747 return 1;
5748 }
5749 else {
5750 int res;
5751 if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
5752 goto failed;
5753 }
5754 res = obj2ast_identifier(state, tmp, &name, arena);
5755 _Py_LeaveRecursiveCall();
5756 if (res != 0) goto failed;
5757 Py_CLEAR(tmp);
5758 }
5759 if (_PyObject_LookupAttr(obj, state->args, &tmp) < 0) {
5760 return 1;
5761 }
5762 if (tmp == NULL) {
5763 PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from FunctionDef");
5764 return 1;
5765 }
5766 else {
5767 int res;
5768 if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
5769 goto failed;
5770 }
5771 res = obj2ast_arguments(state, tmp, &args, arena);
5772 _Py_LeaveRecursiveCall();
5773 if (res != 0) goto failed;
5774 Py_CLEAR(tmp);
5775 }
5776 if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
5777 return 1;
5778 }
5779 if (tmp == NULL) {
5780 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from FunctionDef");
5781 return 1;
5782 }
5783 else {
5784 int res;
5785 Py_ssize_t len;
5786 Py_ssize_t i;
5787 if (!PyList_Check(tmp)) {
5788 PyErr_Format(PyExc_TypeError, "FunctionDef field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
5789 goto failed;
5790 }
5791 len = PyList_GET_SIZE(tmp);
5792 body = _Py_asdl_stmt_seq_new(len, arena);
5793 if (body == NULL) goto failed;
5794 for (i = 0; i < len; i++) {
5795 stmt_ty val;
5796 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
5797 Py_INCREF(tmp2);
5798 if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
5799 goto failed;
5800 }
5801 res = obj2ast_stmt(state, tmp2, &val, arena);
5802 _Py_LeaveRecursiveCall();
5803 Py_DECREF(tmp2);
5804 if (res != 0) goto failed;
5805 if (len != PyList_GET_SIZE(tmp)) {
5806 PyErr_SetString(PyExc_RuntimeError, "FunctionDef field \"body\" changed size during iteration");
5807 goto failed;
5808 }
5809 asdl_seq_SET(body, i, val);
5810 }
5811 Py_CLEAR(tmp);
5812 }
5813 if (_PyObject_LookupAttr(obj, state->decorator_list, &tmp) < 0) {
5814 return 1;
5815 }
5816 if (tmp == NULL) {
5817 PyErr_SetString(PyExc_TypeError, "required field \"decorator_list\" missing from FunctionDef");
5818 return 1;
5819 }
5820 else {
5821 int res;
5822 Py_ssize_t len;
5823 Py_ssize_t i;
5824 if (!PyList_Check(tmp)) {
5825 PyErr_Format(PyExc_TypeError, "FunctionDef field \"decorator_list\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
5826 goto failed;
5827 }
5828 len = PyList_GET_SIZE(tmp);
5829 decorator_list = _Py_asdl_expr_seq_new(len, arena);
5830 if (decorator_list == NULL) goto failed;
5831 for (i = 0; i < len; i++) {
5832 expr_ty val;
5833 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
5834 Py_INCREF(tmp2);
5835 if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
5836 goto failed;
5837 }
5838 res = obj2ast_expr(state, tmp2, &val, arena);
5839 _Py_LeaveRecursiveCall();
5840 Py_DECREF(tmp2);
5841 if (res != 0) goto failed;
5842 if (len != PyList_GET_SIZE(tmp)) {
5843 PyErr_SetString(PyExc_RuntimeError, "FunctionDef field \"decorator_list\" changed size during iteration");
5844 goto failed;
5845 }
5846 asdl_seq_SET(decorator_list, i, val);
5847 }
5848 Py_CLEAR(tmp);
5849 }
5850 if (_PyObject_LookupAttr(obj, state->returns, &tmp) < 0) {
5851 return 1;
5852 }
5853 if (tmp == NULL || tmp == Py_None) {
5854 Py_CLEAR(tmp);
5855 returns = NULL;
5856 }
5857 else {
5858 int res;
5859 if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
5860 goto failed;
5861 }
5862 res = obj2ast_expr(state, tmp, &returns, arena);
5863 _Py_LeaveRecursiveCall();
5864 if (res != 0) goto failed;
5865 Py_CLEAR(tmp);
5866 }
5867 if (_PyObject_LookupAttr(obj, state->type_comment, &tmp) < 0) {
5868 return 1;
5869 }
5870 if (tmp == NULL || tmp == Py_None) {
5871 Py_CLEAR(tmp);
5872 type_comment = NULL;
5873 }
5874 else {
5875 int res;
5876 if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
5877 goto failed;
5878 }
5879 res = obj2ast_string(state, tmp, &type_comment, arena);
5880 _Py_LeaveRecursiveCall();
5881 if (res != 0) goto failed;
5882 Py_CLEAR(tmp);
5883 }
5884 *out = _PyAST_FunctionDef(name, args, body, decorator_list, returns,
5885 type_comment, lineno, col_offset, end_lineno,
5886 end_col_offset, arena);
5887 if (*out == NULL) goto failed;
5888 return 0;
5889 }
5890 tp = state->AsyncFunctionDef_type;
5891 isinstance = PyObject_IsInstance(obj, tp);
5892 if (isinstance == -1) {
5893 return 1;
5894 }
5895 if (isinstance) {
5896 identifier name;
5897 arguments_ty args;
5898 asdl_stmt_seq* body;
5899 asdl_expr_seq* decorator_list;
5900 expr_ty returns;
5901 string type_comment;
5902
5903 if (_PyObject_LookupAttr(obj, state->name, &tmp) < 0) {
5904 return 1;
5905 }
5906 if (tmp == NULL) {
5907 PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from AsyncFunctionDef");
5908 return 1;
5909 }
5910 else {
5911 int res;
5912 if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
5913 goto failed;
5914 }
5915 res = obj2ast_identifier(state, tmp, &name, arena);
5916 _Py_LeaveRecursiveCall();
5917 if (res != 0) goto failed;
5918 Py_CLEAR(tmp);
5919 }
5920 if (_PyObject_LookupAttr(obj, state->args, &tmp) < 0) {
5921 return 1;
5922 }
5923 if (tmp == NULL) {
5924 PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from AsyncFunctionDef");
5925 return 1;
5926 }
5927 else {
5928 int res;
5929 if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
5930 goto failed;
5931 }
5932 res = obj2ast_arguments(state, tmp, &args, arena);
5933 _Py_LeaveRecursiveCall();
5934 if (res != 0) goto failed;
5935 Py_CLEAR(tmp);
5936 }
5937 if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
5938 return 1;
5939 }
5940 if (tmp == NULL) {
5941 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from AsyncFunctionDef");
5942 return 1;
5943 }
5944 else {
5945 int res;
5946 Py_ssize_t len;
5947 Py_ssize_t i;
5948 if (!PyList_Check(tmp)) {
5949 PyErr_Format(PyExc_TypeError, "AsyncFunctionDef field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
5950 goto failed;
5951 }
5952 len = PyList_GET_SIZE(tmp);
5953 body = _Py_asdl_stmt_seq_new(len, arena);
5954 if (body == NULL) goto failed;
5955 for (i = 0; i < len; i++) {
5956 stmt_ty val;
5957 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
5958 Py_INCREF(tmp2);
5959 if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
5960 goto failed;
5961 }
5962 res = obj2ast_stmt(state, tmp2, &val, arena);
5963 _Py_LeaveRecursiveCall();
5964 Py_DECREF(tmp2);
5965 if (res != 0) goto failed;
5966 if (len != PyList_GET_SIZE(tmp)) {
5967 PyErr_SetString(PyExc_RuntimeError, "AsyncFunctionDef field \"body\" changed size during iteration");
5968 goto failed;
5969 }
5970 asdl_seq_SET(body, i, val);
5971 }
5972 Py_CLEAR(tmp);
5973 }
5974 if (_PyObject_LookupAttr(obj, state->decorator_list, &tmp) < 0) {
5975 return 1;
5976 }
5977 if (tmp == NULL) {
5978 PyErr_SetString(PyExc_TypeError, "required field \"decorator_list\" missing from AsyncFunctionDef");
5979 return 1;
5980 }
5981 else {
5982 int res;
5983 Py_ssize_t len;
5984 Py_ssize_t i;
5985 if (!PyList_Check(tmp)) {
5986 PyErr_Format(PyExc_TypeError, "AsyncFunctionDef field \"decorator_list\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
5987 goto failed;
5988 }
5989 len = PyList_GET_SIZE(tmp);
5990 decorator_list = _Py_asdl_expr_seq_new(len, arena);
5991 if (decorator_list == NULL) goto failed;
5992 for (i = 0; i < len; i++) {
5993 expr_ty val;
5994 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
5995 Py_INCREF(tmp2);
5996 if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
5997 goto failed;
5998 }
5999 res = obj2ast_expr(state, tmp2, &val, arena);
6000 _Py_LeaveRecursiveCall();
6001 Py_DECREF(tmp2);
6002 if (res != 0) goto failed;
6003 if (len != PyList_GET_SIZE(tmp)) {
6004 PyErr_SetString(PyExc_RuntimeError, "AsyncFunctionDef field \"decorator_list\" changed size during iteration");
6005 goto failed;
6006 }
6007 asdl_seq_SET(decorator_list, i, val);
6008 }
6009 Py_CLEAR(tmp);
6010 }
6011 if (_PyObject_LookupAttr(obj, state->returns, &tmp) < 0) {
6012 return 1;
6013 }
6014 if (tmp == NULL || tmp == Py_None) {
6015 Py_CLEAR(tmp);
6016 returns = NULL;
6017 }
6018 else {
6019 int res;
6020 if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
6021 goto failed;
6022 }
6023 res = obj2ast_expr(state, tmp, &returns, arena);
6024 _Py_LeaveRecursiveCall();
6025 if (res != 0) goto failed;
6026 Py_CLEAR(tmp);
6027 }
6028 if (_PyObject_LookupAttr(obj, state->type_comment, &tmp) < 0) {
6029 return 1;
6030 }
6031 if (tmp == NULL || tmp == Py_None) {
6032 Py_CLEAR(tmp);
6033 type_comment = NULL;
6034 }
6035 else {
6036 int res;
6037 if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
6038 goto failed;
6039 }
6040 res = obj2ast_string(state, tmp, &type_comment, arena);
6041 _Py_LeaveRecursiveCall();
6042 if (res != 0) goto failed;
6043 Py_CLEAR(tmp);
6044 }
6045 *out = _PyAST_AsyncFunctionDef(name, args, body, decorator_list,
6046 returns, type_comment, lineno,
6047 col_offset, end_lineno, end_col_offset,
6048 arena);
6049 if (*out == NULL) goto failed;
6050 return 0;
6051 }
6052 tp = state->ClassDef_type;
6053 isinstance = PyObject_IsInstance(obj, tp);
6054 if (isinstance == -1) {
6055 return 1;
6056 }
6057 if (isinstance) {
6058 identifier name;
6059 asdl_expr_seq* bases;
6060 asdl_keyword_seq* keywords;
6061 asdl_stmt_seq* body;
6062 asdl_expr_seq* decorator_list;
6063
6064 if (_PyObject_LookupAttr(obj, state->name, &tmp) < 0) {
6065 return 1;
6066 }
6067 if (tmp == NULL) {
6068 PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from ClassDef");
6069 return 1;
6070 }
6071 else {
6072 int res;
6073 if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
6074 goto failed;
6075 }
6076 res = obj2ast_identifier(state, tmp, &name, arena);
6077 _Py_LeaveRecursiveCall();
6078 if (res != 0) goto failed;
6079 Py_CLEAR(tmp);
6080 }
6081 if (_PyObject_LookupAttr(obj, state->bases, &tmp) < 0) {
6082 return 1;
6083 }
6084 if (tmp == NULL) {
6085 PyErr_SetString(PyExc_TypeError, "required field \"bases\" missing from ClassDef");
6086 return 1;
6087 }
6088 else {
6089 int res;
6090 Py_ssize_t len;
6091 Py_ssize_t i;
6092 if (!PyList_Check(tmp)) {
6093 PyErr_Format(PyExc_TypeError, "ClassDef field \"bases\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
6094 goto failed;
6095 }
6096 len = PyList_GET_SIZE(tmp);
6097 bases = _Py_asdl_expr_seq_new(len, arena);
6098 if (bases == NULL) goto failed;
6099 for (i = 0; i < len; i++) {
6100 expr_ty val;
6101 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
6102 Py_INCREF(tmp2);
6103 if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
6104 goto failed;
6105 }
6106 res = obj2ast_expr(state, tmp2, &val, arena);
6107 _Py_LeaveRecursiveCall();
6108 Py_DECREF(tmp2);
6109 if (res != 0) goto failed;
6110 if (len != PyList_GET_SIZE(tmp)) {
6111 PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"bases\" changed size during iteration");
6112 goto failed;
6113 }
6114 asdl_seq_SET(bases, i, val);
6115 }
6116 Py_CLEAR(tmp);
6117 }
6118 if (_PyObject_LookupAttr(obj, state->keywords, &tmp) < 0) {
6119 return 1;
6120 }
6121 if (tmp == NULL) {
6122 PyErr_SetString(PyExc_TypeError, "required field \"keywords\" missing from ClassDef");
6123 return 1;
6124 }
6125 else {
6126 int res;
6127 Py_ssize_t len;
6128 Py_ssize_t i;
6129 if (!PyList_Check(tmp)) {
6130 PyErr_Format(PyExc_TypeError, "ClassDef field \"keywords\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
6131 goto failed;
6132 }
6133 len = PyList_GET_SIZE(tmp);
6134 keywords = _Py_asdl_keyword_seq_new(len, arena);
6135 if (keywords == NULL) goto failed;
6136 for (i = 0; i < len; i++) {
6137 keyword_ty val;
6138 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
6139 Py_INCREF(tmp2);
6140 if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
6141 goto failed;
6142 }
6143 res = obj2ast_keyword(state, tmp2, &val, arena);
6144 _Py_LeaveRecursiveCall();
6145 Py_DECREF(tmp2);
6146 if (res != 0) goto failed;
6147 if (len != PyList_GET_SIZE(tmp)) {
6148 PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"keywords\" changed size during iteration");
6149 goto failed;
6150 }
6151 asdl_seq_SET(keywords, i, val);
6152 }
6153 Py_CLEAR(tmp);
6154 }
6155 if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
6156 return 1;
6157 }
6158 if (tmp == NULL) {
6159 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from ClassDef");
6160 return 1;
6161 }
6162 else {
6163 int res;
6164 Py_ssize_t len;
6165 Py_ssize_t i;
6166 if (!PyList_Check(tmp)) {
6167 PyErr_Format(PyExc_TypeError, "ClassDef field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
6168 goto failed;
6169 }
6170 len = PyList_GET_SIZE(tmp);
6171 body = _Py_asdl_stmt_seq_new(len, arena);
6172 if (body == NULL) goto failed;
6173 for (i = 0; i < len; i++) {
6174 stmt_ty val;
6175 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
6176 Py_INCREF(tmp2);
6177 if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
6178 goto failed;
6179 }
6180 res = obj2ast_stmt(state, tmp2, &val, arena);
6181 _Py_LeaveRecursiveCall();
6182 Py_DECREF(tmp2);
6183 if (res != 0) goto failed;
6184 if (len != PyList_GET_SIZE(tmp)) {
6185 PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"body\" changed size during iteration");
6186 goto failed;
6187 }
6188 asdl_seq_SET(body, i, val);
6189 }
6190 Py_CLEAR(tmp);
6191 }
6192 if (_PyObject_LookupAttr(obj, state->decorator_list, &tmp) < 0) {
6193 return 1;
6194 }
6195 if (tmp == NULL) {
6196 PyErr_SetString(PyExc_TypeError, "required field \"decorator_list\" missing from ClassDef");
6197 return 1;
6198 }
6199 else {
6200 int res;
6201 Py_ssize_t len;
6202 Py_ssize_t i;
6203 if (!PyList_Check(tmp)) {
6204 PyErr_Format(PyExc_TypeError, "ClassDef field \"decorator_list\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
6205 goto failed;
6206 }
6207 len = PyList_GET_SIZE(tmp);
6208 decorator_list = _Py_asdl_expr_seq_new(len, arena);
6209 if (decorator_list == NULL) goto failed;
6210 for (i = 0; i < len; i++) {
6211 expr_ty val;
6212 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
6213 Py_INCREF(tmp2);
6214 if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
6215 goto failed;
6216 }
6217 res = obj2ast_expr(state, tmp2, &val, arena);
6218 _Py_LeaveRecursiveCall();
6219 Py_DECREF(tmp2);
6220 if (res != 0) goto failed;
6221 if (len != PyList_GET_SIZE(tmp)) {
6222 PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"decorator_list\" changed size during iteration");
6223 goto failed;
6224 }
6225 asdl_seq_SET(decorator_list, i, val);
6226 }
6227 Py_CLEAR(tmp);
6228 }
6229 *out = _PyAST_ClassDef(name, bases, keywords, body, decorator_list,
6230 lineno, col_offset, end_lineno, end_col_offset,
6231 arena);
6232 if (*out == NULL) goto failed;
6233 return 0;
6234 }
6235 tp = state->Return_type;
6236 isinstance = PyObject_IsInstance(obj, tp);
6237 if (isinstance == -1) {
6238 return 1;
6239 }
6240 if (isinstance) {
6241 expr_ty value;
6242
6243 if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
6244 return 1;
6245 }
6246 if (tmp == NULL || tmp == Py_None) {
6247 Py_CLEAR(tmp);
6248 value = NULL;
6249 }
6250 else {
6251 int res;
6252 if (_Py_EnterRecursiveCall(" while traversing 'Return' node")) {
6253 goto failed;
6254 }
6255 res = obj2ast_expr(state, tmp, &value, arena);
6256 _Py_LeaveRecursiveCall();
6257 if (res != 0) goto failed;
6258 Py_CLEAR(tmp);
6259 }
6260 *out = _PyAST_Return(value, lineno, col_offset, end_lineno,
6261 end_col_offset, arena);
6262 if (*out == NULL) goto failed;
6263 return 0;
6264 }
6265 tp = state->Delete_type;
6266 isinstance = PyObject_IsInstance(obj, tp);
6267 if (isinstance == -1) {
6268 return 1;
6269 }
6270 if (isinstance) {
6271 asdl_expr_seq* targets;
6272
6273 if (_PyObject_LookupAttr(obj, state->targets, &tmp) < 0) {
6274 return 1;
6275 }
6276 if (tmp == NULL) {
6277 PyErr_SetString(PyExc_TypeError, "required field \"targets\" missing from Delete");
6278 return 1;
6279 }
6280 else {
6281 int res;
6282 Py_ssize_t len;
6283 Py_ssize_t i;
6284 if (!PyList_Check(tmp)) {
6285 PyErr_Format(PyExc_TypeError, "Delete field \"targets\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
6286 goto failed;
6287 }
6288 len = PyList_GET_SIZE(tmp);
6289 targets = _Py_asdl_expr_seq_new(len, arena);
6290 if (targets == NULL) goto failed;
6291 for (i = 0; i < len; i++) {
6292 expr_ty val;
6293 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
6294 Py_INCREF(tmp2);
6295 if (_Py_EnterRecursiveCall(" while traversing 'Delete' node")) {
6296 goto failed;
6297 }
6298 res = obj2ast_expr(state, tmp2, &val, arena);
6299 _Py_LeaveRecursiveCall();
6300 Py_DECREF(tmp2);
6301 if (res != 0) goto failed;
6302 if (len != PyList_GET_SIZE(tmp)) {
6303 PyErr_SetString(PyExc_RuntimeError, "Delete field \"targets\" changed size during iteration");
6304 goto failed;
6305 }
6306 asdl_seq_SET(targets, i, val);
6307 }
6308 Py_CLEAR(tmp);
6309 }
6310 *out = _PyAST_Delete(targets, lineno, col_offset, end_lineno,
6311 end_col_offset, arena);
6312 if (*out == NULL) goto failed;
6313 return 0;
6314 }
6315 tp = state->Assign_type;
6316 isinstance = PyObject_IsInstance(obj, tp);
6317 if (isinstance == -1) {
6318 return 1;
6319 }
6320 if (isinstance) {
6321 asdl_expr_seq* targets;
6322 expr_ty value;
6323 string type_comment;
6324
6325 if (_PyObject_LookupAttr(obj, state->targets, &tmp) < 0) {
6326 return 1;
6327 }
6328 if (tmp == NULL) {
6329 PyErr_SetString(PyExc_TypeError, "required field \"targets\" missing from Assign");
6330 return 1;
6331 }
6332 else {
6333 int res;
6334 Py_ssize_t len;
6335 Py_ssize_t i;
6336 if (!PyList_Check(tmp)) {
6337 PyErr_Format(PyExc_TypeError, "Assign field \"targets\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
6338 goto failed;
6339 }
6340 len = PyList_GET_SIZE(tmp);
6341 targets = _Py_asdl_expr_seq_new(len, arena);
6342 if (targets == NULL) goto failed;
6343 for (i = 0; i < len; i++) {
6344 expr_ty val;
6345 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
6346 Py_INCREF(tmp2);
6347 if (_Py_EnterRecursiveCall(" while traversing 'Assign' node")) {
6348 goto failed;
6349 }
6350 res = obj2ast_expr(state, tmp2, &val, arena);
6351 _Py_LeaveRecursiveCall();
6352 Py_DECREF(tmp2);
6353 if (res != 0) goto failed;
6354 if (len != PyList_GET_SIZE(tmp)) {
6355 PyErr_SetString(PyExc_RuntimeError, "Assign field \"targets\" changed size during iteration");
6356 goto failed;
6357 }
6358 asdl_seq_SET(targets, i, val);
6359 }
6360 Py_CLEAR(tmp);
6361 }
6362 if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
6363 return 1;
6364 }
6365 if (tmp == NULL) {
6366 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Assign");
6367 return 1;
6368 }
6369 else {
6370 int res;
6371 if (_Py_EnterRecursiveCall(" while traversing 'Assign' node")) {
6372 goto failed;
6373 }
6374 res = obj2ast_expr(state, tmp, &value, arena);
6375 _Py_LeaveRecursiveCall();
6376 if (res != 0) goto failed;
6377 Py_CLEAR(tmp);
6378 }
6379 if (_PyObject_LookupAttr(obj, state->type_comment, &tmp) < 0) {
6380 return 1;
6381 }
6382 if (tmp == NULL || tmp == Py_None) {
6383 Py_CLEAR(tmp);
6384 type_comment = NULL;
6385 }
6386 else {
6387 int res;
6388 if (_Py_EnterRecursiveCall(" while traversing 'Assign' node")) {
6389 goto failed;
6390 }
6391 res = obj2ast_string(state, tmp, &type_comment, arena);
6392 _Py_LeaveRecursiveCall();
6393 if (res != 0) goto failed;
6394 Py_CLEAR(tmp);
6395 }
6396 *out = _PyAST_Assign(targets, value, type_comment, lineno, col_offset,
6397 end_lineno, end_col_offset, arena);
6398 if (*out == NULL) goto failed;
6399 return 0;
6400 }
6401 tp = state->AugAssign_type;
6402 isinstance = PyObject_IsInstance(obj, tp);
6403 if (isinstance == -1) {
6404 return 1;
6405 }
6406 if (isinstance) {
6407 expr_ty target;
6408 operator_ty op;
6409 expr_ty value;
6410
6411 if (_PyObject_LookupAttr(obj, state->target, &tmp) < 0) {
6412 return 1;
6413 }
6414 if (tmp == NULL) {
6415 PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from AugAssign");
6416 return 1;
6417 }
6418 else {
6419 int res;
6420 if (_Py_EnterRecursiveCall(" while traversing 'AugAssign' node")) {
6421 goto failed;
6422 }
6423 res = obj2ast_expr(state, tmp, &target, arena);
6424 _Py_LeaveRecursiveCall();
6425 if (res != 0) goto failed;
6426 Py_CLEAR(tmp);
6427 }
6428 if (_PyObject_LookupAttr(obj, state->op, &tmp) < 0) {
6429 return 1;
6430 }
6431 if (tmp == NULL) {
6432 PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from AugAssign");
6433 return 1;
6434 }
6435 else {
6436 int res;
6437 if (_Py_EnterRecursiveCall(" while traversing 'AugAssign' node")) {
6438 goto failed;
6439 }
6440 res = obj2ast_operator(state, tmp, &op, arena);
6441 _Py_LeaveRecursiveCall();
6442 if (res != 0) goto failed;
6443 Py_CLEAR(tmp);
6444 }
6445 if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
6446 return 1;
6447 }
6448 if (tmp == NULL) {
6449 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from AugAssign");
6450 return 1;
6451 }
6452 else {
6453 int res;
6454 if (_Py_EnterRecursiveCall(" while traversing 'AugAssign' node")) {
6455 goto failed;
6456 }
6457 res = obj2ast_expr(state, tmp, &value, arena);
6458 _Py_LeaveRecursiveCall();
6459 if (res != 0) goto failed;
6460 Py_CLEAR(tmp);
6461 }
6462 *out = _PyAST_AugAssign(target, op, value, lineno, col_offset,
6463 end_lineno, end_col_offset, arena);
6464 if (*out == NULL) goto failed;
6465 return 0;
6466 }
6467 tp = state->AnnAssign_type;
6468 isinstance = PyObject_IsInstance(obj, tp);
6469 if (isinstance == -1) {
6470 return 1;
6471 }
6472 if (isinstance) {
6473 expr_ty target;
6474 expr_ty annotation;
6475 expr_ty value;
6476 int simple;
6477
6478 if (_PyObject_LookupAttr(obj, state->target, &tmp) < 0) {
6479 return 1;
6480 }
6481 if (tmp == NULL) {
6482 PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from AnnAssign");
6483 return 1;
6484 }
6485 else {
6486 int res;
6487 if (_Py_EnterRecursiveCall(" while traversing 'AnnAssign' node")) {
6488 goto failed;
6489 }
6490 res = obj2ast_expr(state, tmp, &target, arena);
6491 _Py_LeaveRecursiveCall();
6492 if (res != 0) goto failed;
6493 Py_CLEAR(tmp);
6494 }
6495 if (_PyObject_LookupAttr(obj, state->annotation, &tmp) < 0) {
6496 return 1;
6497 }
6498 if (tmp == NULL) {
6499 PyErr_SetString(PyExc_TypeError, "required field \"annotation\" missing from AnnAssign");
6500 return 1;
6501 }
6502 else {
6503 int res;
6504 if (_Py_EnterRecursiveCall(" while traversing 'AnnAssign' node")) {
6505 goto failed;
6506 }
6507 res = obj2ast_expr(state, tmp, &annotation, arena);
6508 _Py_LeaveRecursiveCall();
6509 if (res != 0) goto failed;
6510 Py_CLEAR(tmp);
6511 }
6512 if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
6513 return 1;
6514 }
6515 if (tmp == NULL || tmp == Py_None) {
6516 Py_CLEAR(tmp);
6517 value = NULL;
6518 }
6519 else {
6520 int res;
6521 if (_Py_EnterRecursiveCall(" while traversing 'AnnAssign' node")) {
6522 goto failed;
6523 }
6524 res = obj2ast_expr(state, tmp, &value, arena);
6525 _Py_LeaveRecursiveCall();
6526 if (res != 0) goto failed;
6527 Py_CLEAR(tmp);
6528 }
6529 if (_PyObject_LookupAttr(obj, state->simple, &tmp) < 0) {
6530 return 1;
6531 }
6532 if (tmp == NULL) {
6533 PyErr_SetString(PyExc_TypeError, "required field \"simple\" missing from AnnAssign");
6534 return 1;
6535 }
6536 else {
6537 int res;
6538 if (_Py_EnterRecursiveCall(" while traversing 'AnnAssign' node")) {
6539 goto failed;
6540 }
6541 res = obj2ast_int(state, tmp, &simple, arena);
6542 _Py_LeaveRecursiveCall();
6543 if (res != 0) goto failed;
6544 Py_CLEAR(tmp);
6545 }
6546 *out = _PyAST_AnnAssign(target, annotation, value, simple, lineno,
6547 col_offset, end_lineno, end_col_offset, arena);
6548 if (*out == NULL) goto failed;
6549 return 0;
6550 }
6551 tp = state->For_type;
6552 isinstance = PyObject_IsInstance(obj, tp);
6553 if (isinstance == -1) {
6554 return 1;
6555 }
6556 if (isinstance) {
6557 expr_ty target;
6558 expr_ty iter;
6559 asdl_stmt_seq* body;
6560 asdl_stmt_seq* orelse;
6561 string type_comment;
6562
6563 if (_PyObject_LookupAttr(obj, state->target, &tmp) < 0) {
6564 return 1;
6565 }
6566 if (tmp == NULL) {
6567 PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from For");
6568 return 1;
6569 }
6570 else {
6571 int res;
6572 if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
6573 goto failed;
6574 }
6575 res = obj2ast_expr(state, tmp, &target, arena);
6576 _Py_LeaveRecursiveCall();
6577 if (res != 0) goto failed;
6578 Py_CLEAR(tmp);
6579 }
6580 if (_PyObject_LookupAttr(obj, state->iter, &tmp) < 0) {
6581 return 1;
6582 }
6583 if (tmp == NULL) {
6584 PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from For");
6585 return 1;
6586 }
6587 else {
6588 int res;
6589 if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
6590 goto failed;
6591 }
6592 res = obj2ast_expr(state, tmp, &iter, arena);
6593 _Py_LeaveRecursiveCall();
6594 if (res != 0) goto failed;
6595 Py_CLEAR(tmp);
6596 }
6597 if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
6598 return 1;
6599 }
6600 if (tmp == NULL) {
6601 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from For");
6602 return 1;
6603 }
6604 else {
6605 int res;
6606 Py_ssize_t len;
6607 Py_ssize_t i;
6608 if (!PyList_Check(tmp)) {
6609 PyErr_Format(PyExc_TypeError, "For field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
6610 goto failed;
6611 }
6612 len = PyList_GET_SIZE(tmp);
6613 body = _Py_asdl_stmt_seq_new(len, arena);
6614 if (body == NULL) goto failed;
6615 for (i = 0; i < len; i++) {
6616 stmt_ty val;
6617 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
6618 Py_INCREF(tmp2);
6619 if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
6620 goto failed;
6621 }
6622 res = obj2ast_stmt(state, tmp2, &val, arena);
6623 _Py_LeaveRecursiveCall();
6624 Py_DECREF(tmp2);
6625 if (res != 0) goto failed;
6626 if (len != PyList_GET_SIZE(tmp)) {
6627 PyErr_SetString(PyExc_RuntimeError, "For field \"body\" changed size during iteration");
6628 goto failed;
6629 }
6630 asdl_seq_SET(body, i, val);
6631 }
6632 Py_CLEAR(tmp);
6633 }
6634 if (_PyObject_LookupAttr(obj, state->orelse, &tmp) < 0) {
6635 return 1;
6636 }
6637 if (tmp == NULL) {
6638 PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from For");
6639 return 1;
6640 }
6641 else {
6642 int res;
6643 Py_ssize_t len;
6644 Py_ssize_t i;
6645 if (!PyList_Check(tmp)) {
6646 PyErr_Format(PyExc_TypeError, "For field \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
6647 goto failed;
6648 }
6649 len = PyList_GET_SIZE(tmp);
6650 orelse = _Py_asdl_stmt_seq_new(len, arena);
6651 if (orelse == NULL) goto failed;
6652 for (i = 0; i < len; i++) {
6653 stmt_ty val;
6654 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
6655 Py_INCREF(tmp2);
6656 if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
6657 goto failed;
6658 }
6659 res = obj2ast_stmt(state, tmp2, &val, arena);
6660 _Py_LeaveRecursiveCall();
6661 Py_DECREF(tmp2);
6662 if (res != 0) goto failed;
6663 if (len != PyList_GET_SIZE(tmp)) {
6664 PyErr_SetString(PyExc_RuntimeError, "For field \"orelse\" changed size during iteration");
6665 goto failed;
6666 }
6667 asdl_seq_SET(orelse, i, val);
6668 }
6669 Py_CLEAR(tmp);
6670 }
6671 if (_PyObject_LookupAttr(obj, state->type_comment, &tmp) < 0) {
6672 return 1;
6673 }
6674 if (tmp == NULL || tmp == Py_None) {
6675 Py_CLEAR(tmp);
6676 type_comment = NULL;
6677 }
6678 else {
6679 int res;
6680 if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
6681 goto failed;
6682 }
6683 res = obj2ast_string(state, tmp, &type_comment, arena);
6684 _Py_LeaveRecursiveCall();
6685 if (res != 0) goto failed;
6686 Py_CLEAR(tmp);
6687 }
6688 *out = _PyAST_For(target, iter, body, orelse, type_comment, lineno,
6689 col_offset, end_lineno, end_col_offset, arena);
6690 if (*out == NULL) goto failed;
6691 return 0;
6692 }
6693 tp = state->AsyncFor_type;
6694 isinstance = PyObject_IsInstance(obj, tp);
6695 if (isinstance == -1) {
6696 return 1;
6697 }
6698 if (isinstance) {
6699 expr_ty target;
6700 expr_ty iter;
6701 asdl_stmt_seq* body;
6702 asdl_stmt_seq* orelse;
6703 string type_comment;
6704
6705 if (_PyObject_LookupAttr(obj, state->target, &tmp) < 0) {
6706 return 1;
6707 }
6708 if (tmp == NULL) {
6709 PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from AsyncFor");
6710 return 1;
6711 }
6712 else {
6713 int res;
6714 if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
6715 goto failed;
6716 }
6717 res = obj2ast_expr(state, tmp, &target, arena);
6718 _Py_LeaveRecursiveCall();
6719 if (res != 0) goto failed;
6720 Py_CLEAR(tmp);
6721 }
6722 if (_PyObject_LookupAttr(obj, state->iter, &tmp) < 0) {
6723 return 1;
6724 }
6725 if (tmp == NULL) {
6726 PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from AsyncFor");
6727 return 1;
6728 }
6729 else {
6730 int res;
6731 if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
6732 goto failed;
6733 }
6734 res = obj2ast_expr(state, tmp, &iter, arena);
6735 _Py_LeaveRecursiveCall();
6736 if (res != 0) goto failed;
6737 Py_CLEAR(tmp);
6738 }
6739 if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
6740 return 1;
6741 }
6742 if (tmp == NULL) {
6743 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from AsyncFor");
6744 return 1;
6745 }
6746 else {
6747 int res;
6748 Py_ssize_t len;
6749 Py_ssize_t i;
6750 if (!PyList_Check(tmp)) {
6751 PyErr_Format(PyExc_TypeError, "AsyncFor field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
6752 goto failed;
6753 }
6754 len = PyList_GET_SIZE(tmp);
6755 body = _Py_asdl_stmt_seq_new(len, arena);
6756 if (body == NULL) goto failed;
6757 for (i = 0; i < len; i++) {
6758 stmt_ty val;
6759 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
6760 Py_INCREF(tmp2);
6761 if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
6762 goto failed;
6763 }
6764 res = obj2ast_stmt(state, tmp2, &val, arena);
6765 _Py_LeaveRecursiveCall();
6766 Py_DECREF(tmp2);
6767 if (res != 0) goto failed;
6768 if (len != PyList_GET_SIZE(tmp)) {
6769 PyErr_SetString(PyExc_RuntimeError, "AsyncFor field \"body\" changed size during iteration");
6770 goto failed;
6771 }
6772 asdl_seq_SET(body, i, val);
6773 }
6774 Py_CLEAR(tmp);
6775 }
6776 if (_PyObject_LookupAttr(obj, state->orelse, &tmp) < 0) {
6777 return 1;
6778 }
6779 if (tmp == NULL) {
6780 PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from AsyncFor");
6781 return 1;
6782 }
6783 else {
6784 int res;
6785 Py_ssize_t len;
6786 Py_ssize_t i;
6787 if (!PyList_Check(tmp)) {
6788 PyErr_Format(PyExc_TypeError, "AsyncFor field \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
6789 goto failed;
6790 }
6791 len = PyList_GET_SIZE(tmp);
6792 orelse = _Py_asdl_stmt_seq_new(len, arena);
6793 if (orelse == NULL) goto failed;
6794 for (i = 0; i < len; i++) {
6795 stmt_ty val;
6796 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
6797 Py_INCREF(tmp2);
6798 if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
6799 goto failed;
6800 }
6801 res = obj2ast_stmt(state, tmp2, &val, arena);
6802 _Py_LeaveRecursiveCall();
6803 Py_DECREF(tmp2);
6804 if (res != 0) goto failed;
6805 if (len != PyList_GET_SIZE(tmp)) {
6806 PyErr_SetString(PyExc_RuntimeError, "AsyncFor field \"orelse\" changed size during iteration");
6807 goto failed;
6808 }
6809 asdl_seq_SET(orelse, i, val);
6810 }
6811 Py_CLEAR(tmp);
6812 }
6813 if (_PyObject_LookupAttr(obj, state->type_comment, &tmp) < 0) {
6814 return 1;
6815 }
6816 if (tmp == NULL || tmp == Py_None) {
6817 Py_CLEAR(tmp);
6818 type_comment = NULL;
6819 }
6820 else {
6821 int res;
6822 if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
6823 goto failed;
6824 }
6825 res = obj2ast_string(state, tmp, &type_comment, arena);
6826 _Py_LeaveRecursiveCall();
6827 if (res != 0) goto failed;
6828 Py_CLEAR(tmp);
6829 }
6830 *out = _PyAST_AsyncFor(target, iter, body, orelse, type_comment,
6831 lineno, col_offset, end_lineno, end_col_offset,
6832 arena);
6833 if (*out == NULL) goto failed;
6834 return 0;
6835 }
6836 tp = state->While_type;
6837 isinstance = PyObject_IsInstance(obj, tp);
6838 if (isinstance == -1) {
6839 return 1;
6840 }
6841 if (isinstance) {
6842 expr_ty test;
6843 asdl_stmt_seq* body;
6844 asdl_stmt_seq* orelse;
6845
6846 if (_PyObject_LookupAttr(obj, state->test, &tmp) < 0) {
6847 return 1;
6848 }
6849 if (tmp == NULL) {
6850 PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from While");
6851 return 1;
6852 }
6853 else {
6854 int res;
6855 if (_Py_EnterRecursiveCall(" while traversing 'While' node")) {
6856 goto failed;
6857 }
6858 res = obj2ast_expr(state, tmp, &test, arena);
6859 _Py_LeaveRecursiveCall();
6860 if (res != 0) goto failed;
6861 Py_CLEAR(tmp);
6862 }
6863 if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
6864 return 1;
6865 }
6866 if (tmp == NULL) {
6867 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from While");
6868 return 1;
6869 }
6870 else {
6871 int res;
6872 Py_ssize_t len;
6873 Py_ssize_t i;
6874 if (!PyList_Check(tmp)) {
6875 PyErr_Format(PyExc_TypeError, "While field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
6876 goto failed;
6877 }
6878 len = PyList_GET_SIZE(tmp);
6879 body = _Py_asdl_stmt_seq_new(len, arena);
6880 if (body == NULL) goto failed;
6881 for (i = 0; i < len; i++) {
6882 stmt_ty val;
6883 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
6884 Py_INCREF(tmp2);
6885 if (_Py_EnterRecursiveCall(" while traversing 'While' node")) {
6886 goto failed;
6887 }
6888 res = obj2ast_stmt(state, tmp2, &val, arena);
6889 _Py_LeaveRecursiveCall();
6890 Py_DECREF(tmp2);
6891 if (res != 0) goto failed;
6892 if (len != PyList_GET_SIZE(tmp)) {
6893 PyErr_SetString(PyExc_RuntimeError, "While field \"body\" changed size during iteration");
6894 goto failed;
6895 }
6896 asdl_seq_SET(body, i, val);
6897 }
6898 Py_CLEAR(tmp);
6899 }
6900 if (_PyObject_LookupAttr(obj, state->orelse, &tmp) < 0) {
6901 return 1;
6902 }
6903 if (tmp == NULL) {
6904 PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from While");
6905 return 1;
6906 }
6907 else {
6908 int res;
6909 Py_ssize_t len;
6910 Py_ssize_t i;
6911 if (!PyList_Check(tmp)) {
6912 PyErr_Format(PyExc_TypeError, "While field \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
6913 goto failed;
6914 }
6915 len = PyList_GET_SIZE(tmp);
6916 orelse = _Py_asdl_stmt_seq_new(len, arena);
6917 if (orelse == NULL) goto failed;
6918 for (i = 0; i < len; i++) {
6919 stmt_ty val;
6920 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
6921 Py_INCREF(tmp2);
6922 if (_Py_EnterRecursiveCall(" while traversing 'While' node")) {
6923 goto failed;
6924 }
6925 res = obj2ast_stmt(state, tmp2, &val, arena);
6926 _Py_LeaveRecursiveCall();
6927 Py_DECREF(tmp2);
6928 if (res != 0) goto failed;
6929 if (len != PyList_GET_SIZE(tmp)) {
6930 PyErr_SetString(PyExc_RuntimeError, "While field \"orelse\" changed size during iteration");
6931 goto failed;
6932 }
6933 asdl_seq_SET(orelse, i, val);
6934 }
6935 Py_CLEAR(tmp);
6936 }
6937 *out = _PyAST_While(test, body, orelse, lineno, col_offset, end_lineno,
6938 end_col_offset, arena);
6939 if (*out == NULL) goto failed;
6940 return 0;
6941 }
6942 tp = state->If_type;
6943 isinstance = PyObject_IsInstance(obj, tp);
6944 if (isinstance == -1) {
6945 return 1;
6946 }
6947 if (isinstance) {
6948 expr_ty test;
6949 asdl_stmt_seq* body;
6950 asdl_stmt_seq* orelse;
6951
6952 if (_PyObject_LookupAttr(obj, state->test, &tmp) < 0) {
6953 return 1;
6954 }
6955 if (tmp == NULL) {
6956 PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from If");
6957 return 1;
6958 }
6959 else {
6960 int res;
6961 if (_Py_EnterRecursiveCall(" while traversing 'If' node")) {
6962 goto failed;
6963 }
6964 res = obj2ast_expr(state, tmp, &test, arena);
6965 _Py_LeaveRecursiveCall();
6966 if (res != 0) goto failed;
6967 Py_CLEAR(tmp);
6968 }
6969 if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
6970 return 1;
6971 }
6972 if (tmp == NULL) {
6973 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from If");
6974 return 1;
6975 }
6976 else {
6977 int res;
6978 Py_ssize_t len;
6979 Py_ssize_t i;
6980 if (!PyList_Check(tmp)) {
6981 PyErr_Format(PyExc_TypeError, "If field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
6982 goto failed;
6983 }
6984 len = PyList_GET_SIZE(tmp);
6985 body = _Py_asdl_stmt_seq_new(len, arena);
6986 if (body == NULL) goto failed;
6987 for (i = 0; i < len; i++) {
6988 stmt_ty val;
6989 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
6990 Py_INCREF(tmp2);
6991 if (_Py_EnterRecursiveCall(" while traversing 'If' node")) {
6992 goto failed;
6993 }
6994 res = obj2ast_stmt(state, tmp2, &val, arena);
6995 _Py_LeaveRecursiveCall();
6996 Py_DECREF(tmp2);
6997 if (res != 0) goto failed;
6998 if (len != PyList_GET_SIZE(tmp)) {
6999 PyErr_SetString(PyExc_RuntimeError, "If field \"body\" changed size during iteration");
7000 goto failed;
7001 }
7002 asdl_seq_SET(body, i, val);
7003 }
7004 Py_CLEAR(tmp);
7005 }
7006 if (_PyObject_LookupAttr(obj, state->orelse, &tmp) < 0) {
7007 return 1;
7008 }
7009 if (tmp == NULL) {
7010 PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from If");
7011 return 1;
7012 }
7013 else {
7014 int res;
7015 Py_ssize_t len;
7016 Py_ssize_t i;
7017 if (!PyList_Check(tmp)) {
7018 PyErr_Format(PyExc_TypeError, "If field \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
7019 goto failed;
7020 }
7021 len = PyList_GET_SIZE(tmp);
7022 orelse = _Py_asdl_stmt_seq_new(len, arena);
7023 if (orelse == NULL) goto failed;
7024 for (i = 0; i < len; i++) {
7025 stmt_ty val;
7026 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
7027 Py_INCREF(tmp2);
7028 if (_Py_EnterRecursiveCall(" while traversing 'If' node")) {
7029 goto failed;
7030 }
7031 res = obj2ast_stmt(state, tmp2, &val, arena);
7032 _Py_LeaveRecursiveCall();
7033 Py_DECREF(tmp2);
7034 if (res != 0) goto failed;
7035 if (len != PyList_GET_SIZE(tmp)) {
7036 PyErr_SetString(PyExc_RuntimeError, "If field \"orelse\" changed size during iteration");
7037 goto failed;
7038 }
7039 asdl_seq_SET(orelse, i, val);
7040 }
7041 Py_CLEAR(tmp);
7042 }
7043 *out = _PyAST_If(test, body, orelse, lineno, col_offset, end_lineno,
7044 end_col_offset, arena);
7045 if (*out == NULL) goto failed;
7046 return 0;
7047 }
7048 tp = state->With_type;
7049 isinstance = PyObject_IsInstance(obj, tp);
7050 if (isinstance == -1) {
7051 return 1;
7052 }
7053 if (isinstance) {
7054 asdl_withitem_seq* items;
7055 asdl_stmt_seq* body;
7056 string type_comment;
7057
7058 if (_PyObject_LookupAttr(obj, state->items, &tmp) < 0) {
7059 return 1;
7060 }
7061 if (tmp == NULL) {
7062 PyErr_SetString(PyExc_TypeError, "required field \"items\" missing from With");
7063 return 1;
7064 }
7065 else {
7066 int res;
7067 Py_ssize_t len;
7068 Py_ssize_t i;
7069 if (!PyList_Check(tmp)) {
7070 PyErr_Format(PyExc_TypeError, "With field \"items\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
7071 goto failed;
7072 }
7073 len = PyList_GET_SIZE(tmp);
7074 items = _Py_asdl_withitem_seq_new(len, arena);
7075 if (items == NULL) goto failed;
7076 for (i = 0; i < len; i++) {
7077 withitem_ty val;
7078 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
7079 Py_INCREF(tmp2);
7080 if (_Py_EnterRecursiveCall(" while traversing 'With' node")) {
7081 goto failed;
7082 }
7083 res = obj2ast_withitem(state, tmp2, &val, arena);
7084 _Py_LeaveRecursiveCall();
7085 Py_DECREF(tmp2);
7086 if (res != 0) goto failed;
7087 if (len != PyList_GET_SIZE(tmp)) {
7088 PyErr_SetString(PyExc_RuntimeError, "With field \"items\" changed size during iteration");
7089 goto failed;
7090 }
7091 asdl_seq_SET(items, i, val);
7092 }
7093 Py_CLEAR(tmp);
7094 }
7095 if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
7096 return 1;
7097 }
7098 if (tmp == NULL) {
7099 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from With");
7100 return 1;
7101 }
7102 else {
7103 int res;
7104 Py_ssize_t len;
7105 Py_ssize_t i;
7106 if (!PyList_Check(tmp)) {
7107 PyErr_Format(PyExc_TypeError, "With field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
7108 goto failed;
7109 }
7110 len = PyList_GET_SIZE(tmp);
7111 body = _Py_asdl_stmt_seq_new(len, arena);
7112 if (body == NULL) goto failed;
7113 for (i = 0; i < len; i++) {
7114 stmt_ty val;
7115 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
7116 Py_INCREF(tmp2);
7117 if (_Py_EnterRecursiveCall(" while traversing 'With' node")) {
7118 goto failed;
7119 }
7120 res = obj2ast_stmt(state, tmp2, &val, arena);
7121 _Py_LeaveRecursiveCall();
7122 Py_DECREF(tmp2);
7123 if (res != 0) goto failed;
7124 if (len != PyList_GET_SIZE(tmp)) {
7125 PyErr_SetString(PyExc_RuntimeError, "With field \"body\" changed size during iteration");
7126 goto failed;
7127 }
7128 asdl_seq_SET(body, i, val);
7129 }
7130 Py_CLEAR(tmp);
7131 }
7132 if (_PyObject_LookupAttr(obj, state->type_comment, &tmp) < 0) {
7133 return 1;
7134 }
7135 if (tmp == NULL || tmp == Py_None) {
7136 Py_CLEAR(tmp);
7137 type_comment = NULL;
7138 }
7139 else {
7140 int res;
7141 if (_Py_EnterRecursiveCall(" while traversing 'With' node")) {
7142 goto failed;
7143 }
7144 res = obj2ast_string(state, tmp, &type_comment, arena);
7145 _Py_LeaveRecursiveCall();
7146 if (res != 0) goto failed;
7147 Py_CLEAR(tmp);
7148 }
7149 *out = _PyAST_With(items, body, type_comment, lineno, col_offset,
7150 end_lineno, end_col_offset, arena);
7151 if (*out == NULL) goto failed;
7152 return 0;
7153 }
7154 tp = state->AsyncWith_type;
7155 isinstance = PyObject_IsInstance(obj, tp);
7156 if (isinstance == -1) {
7157 return 1;
7158 }
7159 if (isinstance) {
7160 asdl_withitem_seq* items;
7161 asdl_stmt_seq* body;
7162 string type_comment;
7163
7164 if (_PyObject_LookupAttr(obj, state->items, &tmp) < 0) {
7165 return 1;
7166 }
7167 if (tmp == NULL) {
7168 PyErr_SetString(PyExc_TypeError, "required field \"items\" missing from AsyncWith");
7169 return 1;
7170 }
7171 else {
7172 int res;
7173 Py_ssize_t len;
7174 Py_ssize_t i;
7175 if (!PyList_Check(tmp)) {
7176 PyErr_Format(PyExc_TypeError, "AsyncWith field \"items\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
7177 goto failed;
7178 }
7179 len = PyList_GET_SIZE(tmp);
7180 items = _Py_asdl_withitem_seq_new(len, arena);
7181 if (items == NULL) goto failed;
7182 for (i = 0; i < len; i++) {
7183 withitem_ty val;
7184 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
7185 Py_INCREF(tmp2);
7186 if (_Py_EnterRecursiveCall(" while traversing 'AsyncWith' node")) {
7187 goto failed;
7188 }
7189 res = obj2ast_withitem(state, tmp2, &val, arena);
7190 _Py_LeaveRecursiveCall();
7191 Py_DECREF(tmp2);
7192 if (res != 0) goto failed;
7193 if (len != PyList_GET_SIZE(tmp)) {
7194 PyErr_SetString(PyExc_RuntimeError, "AsyncWith field \"items\" changed size during iteration");
7195 goto failed;
7196 }
7197 asdl_seq_SET(items, i, val);
7198 }
7199 Py_CLEAR(tmp);
7200 }
7201 if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
7202 return 1;
7203 }
7204 if (tmp == NULL) {
7205 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from AsyncWith");
7206 return 1;
7207 }
7208 else {
7209 int res;
7210 Py_ssize_t len;
7211 Py_ssize_t i;
7212 if (!PyList_Check(tmp)) {
7213 PyErr_Format(PyExc_TypeError, "AsyncWith field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
7214 goto failed;
7215 }
7216 len = PyList_GET_SIZE(tmp);
7217 body = _Py_asdl_stmt_seq_new(len, arena);
7218 if (body == NULL) goto failed;
7219 for (i = 0; i < len; i++) {
7220 stmt_ty val;
7221 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
7222 Py_INCREF(tmp2);
7223 if (_Py_EnterRecursiveCall(" while traversing 'AsyncWith' node")) {
7224 goto failed;
7225 }
7226 res = obj2ast_stmt(state, tmp2, &val, arena);
7227 _Py_LeaveRecursiveCall();
7228 Py_DECREF(tmp2);
7229 if (res != 0) goto failed;
7230 if (len != PyList_GET_SIZE(tmp)) {
7231 PyErr_SetString(PyExc_RuntimeError, "AsyncWith field \"body\" changed size during iteration");
7232 goto failed;
7233 }
7234 asdl_seq_SET(body, i, val);
7235 }
7236 Py_CLEAR(tmp);
7237 }
7238 if (_PyObject_LookupAttr(obj, state->type_comment, &tmp) < 0) {
7239 return 1;
7240 }
7241 if (tmp == NULL || tmp == Py_None) {
7242 Py_CLEAR(tmp);
7243 type_comment = NULL;
7244 }
7245 else {
7246 int res;
7247 if (_Py_EnterRecursiveCall(" while traversing 'AsyncWith' node")) {
7248 goto failed;
7249 }
7250 res = obj2ast_string(state, tmp, &type_comment, arena);
7251 _Py_LeaveRecursiveCall();
7252 if (res != 0) goto failed;
7253 Py_CLEAR(tmp);
7254 }
7255 *out = _PyAST_AsyncWith(items, body, type_comment, lineno, col_offset,
7256 end_lineno, end_col_offset, arena);
7257 if (*out == NULL) goto failed;
7258 return 0;
7259 }
7260 tp = state->Match_type;
7261 isinstance = PyObject_IsInstance(obj, tp);
7262 if (isinstance == -1) {
7263 return 1;
7264 }
7265 if (isinstance) {
7266 expr_ty subject;
7267 asdl_match_case_seq* cases;
7268
7269 if (_PyObject_LookupAttr(obj, state->subject, &tmp) < 0) {
7270 return 1;
7271 }
7272 if (tmp == NULL) {
7273 PyErr_SetString(PyExc_TypeError, "required field \"subject\" missing from Match");
7274 return 1;
7275 }
7276 else {
7277 int res;
7278 if (_Py_EnterRecursiveCall(" while traversing 'Match' node")) {
7279 goto failed;
7280 }
7281 res = obj2ast_expr(state, tmp, &subject, arena);
7282 _Py_LeaveRecursiveCall();
7283 if (res != 0) goto failed;
7284 Py_CLEAR(tmp);
7285 }
7286 if (_PyObject_LookupAttr(obj, state->cases, &tmp) < 0) {
7287 return 1;
7288 }
7289 if (tmp == NULL) {
7290 PyErr_SetString(PyExc_TypeError, "required field \"cases\" missing from Match");
7291 return 1;
7292 }
7293 else {
7294 int res;
7295 Py_ssize_t len;
7296 Py_ssize_t i;
7297 if (!PyList_Check(tmp)) {
7298 PyErr_Format(PyExc_TypeError, "Match field \"cases\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
7299 goto failed;
7300 }
7301 len = PyList_GET_SIZE(tmp);
7302 cases = _Py_asdl_match_case_seq_new(len, arena);
7303 if (cases == NULL) goto failed;
7304 for (i = 0; i < len; i++) {
7305 match_case_ty val;
7306 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
7307 Py_INCREF(tmp2);
7308 if (_Py_EnterRecursiveCall(" while traversing 'Match' node")) {
7309 goto failed;
7310 }
7311 res = obj2ast_match_case(state, tmp2, &val, arena);
7312 _Py_LeaveRecursiveCall();
7313 Py_DECREF(tmp2);
7314 if (res != 0) goto failed;
7315 if (len != PyList_GET_SIZE(tmp)) {
7316 PyErr_SetString(PyExc_RuntimeError, "Match field \"cases\" changed size during iteration");
7317 goto failed;
7318 }
7319 asdl_seq_SET(cases, i, val);
7320 }
7321 Py_CLEAR(tmp);
7322 }
7323 *out = _PyAST_Match(subject, cases, lineno, col_offset, end_lineno,
7324 end_col_offset, arena);
7325 if (*out == NULL) goto failed;
7326 return 0;
7327 }
7328 tp = state->Raise_type;
7329 isinstance = PyObject_IsInstance(obj, tp);
7330 if (isinstance == -1) {
7331 return 1;
7332 }
7333 if (isinstance) {
7334 expr_ty exc;
7335 expr_ty cause;
7336
7337 if (_PyObject_LookupAttr(obj, state->exc, &tmp) < 0) {
7338 return 1;
7339 }
7340 if (tmp == NULL || tmp == Py_None) {
7341 Py_CLEAR(tmp);
7342 exc = NULL;
7343 }
7344 else {
7345 int res;
7346 if (_Py_EnterRecursiveCall(" while traversing 'Raise' node")) {
7347 goto failed;
7348 }
7349 res = obj2ast_expr(state, tmp, &exc, arena);
7350 _Py_LeaveRecursiveCall();
7351 if (res != 0) goto failed;
7352 Py_CLEAR(tmp);
7353 }
7354 if (_PyObject_LookupAttr(obj, state->cause, &tmp) < 0) {
7355 return 1;
7356 }
7357 if (tmp == NULL || tmp == Py_None) {
7358 Py_CLEAR(tmp);
7359 cause = NULL;
7360 }
7361 else {
7362 int res;
7363 if (_Py_EnterRecursiveCall(" while traversing 'Raise' node")) {
7364 goto failed;
7365 }
7366 res = obj2ast_expr(state, tmp, &cause, arena);
7367 _Py_LeaveRecursiveCall();
7368 if (res != 0) goto failed;
7369 Py_CLEAR(tmp);
7370 }
7371 *out = _PyAST_Raise(exc, cause, lineno, col_offset, end_lineno,
7372 end_col_offset, arena);
7373 if (*out == NULL) goto failed;
7374 return 0;
7375 }
7376 tp = state->Try_type;
7377 isinstance = PyObject_IsInstance(obj, tp);
7378 if (isinstance == -1) {
7379 return 1;
7380 }
7381 if (isinstance) {
7382 asdl_stmt_seq* body;
7383 asdl_excepthandler_seq* handlers;
7384 asdl_stmt_seq* orelse;
7385 asdl_stmt_seq* finalbody;
7386
7387 if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
7388 return 1;
7389 }
7390 if (tmp == NULL) {
7391 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Try");
7392 return 1;
7393 }
7394 else {
7395 int res;
7396 Py_ssize_t len;
7397 Py_ssize_t i;
7398 if (!PyList_Check(tmp)) {
7399 PyErr_Format(PyExc_TypeError, "Try field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
7400 goto failed;
7401 }
7402 len = PyList_GET_SIZE(tmp);
7403 body = _Py_asdl_stmt_seq_new(len, arena);
7404 if (body == NULL) goto failed;
7405 for (i = 0; i < len; i++) {
7406 stmt_ty val;
7407 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
7408 Py_INCREF(tmp2);
7409 if (_Py_EnterRecursiveCall(" while traversing 'Try' node")) {
7410 goto failed;
7411 }
7412 res = obj2ast_stmt(state, tmp2, &val, arena);
7413 _Py_LeaveRecursiveCall();
7414 Py_DECREF(tmp2);
7415 if (res != 0) goto failed;
7416 if (len != PyList_GET_SIZE(tmp)) {
7417 PyErr_SetString(PyExc_RuntimeError, "Try field \"body\" changed size during iteration");
7418 goto failed;
7419 }
7420 asdl_seq_SET(body, i, val);
7421 }
7422 Py_CLEAR(tmp);
7423 }
7424 if (_PyObject_LookupAttr(obj, state->handlers, &tmp) < 0) {
7425 return 1;
7426 }
7427 if (tmp == NULL) {
7428 PyErr_SetString(PyExc_TypeError, "required field \"handlers\" missing from Try");
7429 return 1;
7430 }
7431 else {
7432 int res;
7433 Py_ssize_t len;
7434 Py_ssize_t i;
7435 if (!PyList_Check(tmp)) {
7436 PyErr_Format(PyExc_TypeError, "Try field \"handlers\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
7437 goto failed;
7438 }
7439 len = PyList_GET_SIZE(tmp);
7440 handlers = _Py_asdl_excepthandler_seq_new(len, arena);
7441 if (handlers == NULL) goto failed;
7442 for (i = 0; i < len; i++) {
7443 excepthandler_ty val;
7444 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
7445 Py_INCREF(tmp2);
7446 if (_Py_EnterRecursiveCall(" while traversing 'Try' node")) {
7447 goto failed;
7448 }
7449 res = obj2ast_excepthandler(state, tmp2, &val, arena);
7450 _Py_LeaveRecursiveCall();
7451 Py_DECREF(tmp2);
7452 if (res != 0) goto failed;
7453 if (len != PyList_GET_SIZE(tmp)) {
7454 PyErr_SetString(PyExc_RuntimeError, "Try field \"handlers\" changed size during iteration");
7455 goto failed;
7456 }
7457 asdl_seq_SET(handlers, i, val);
7458 }
7459 Py_CLEAR(tmp);
7460 }
7461 if (_PyObject_LookupAttr(obj, state->orelse, &tmp) < 0) {
7462 return 1;
7463 }
7464 if (tmp == NULL) {
7465 PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from Try");
7466 return 1;
7467 }
7468 else {
7469 int res;
7470 Py_ssize_t len;
7471 Py_ssize_t i;
7472 if (!PyList_Check(tmp)) {
7473 PyErr_Format(PyExc_TypeError, "Try field \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
7474 goto failed;
7475 }
7476 len = PyList_GET_SIZE(tmp);
7477 orelse = _Py_asdl_stmt_seq_new(len, arena);
7478 if (orelse == NULL) goto failed;
7479 for (i = 0; i < len; i++) {
7480 stmt_ty val;
7481 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
7482 Py_INCREF(tmp2);
7483 if (_Py_EnterRecursiveCall(" while traversing 'Try' node")) {
7484 goto failed;
7485 }
7486 res = obj2ast_stmt(state, tmp2, &val, arena);
7487 _Py_LeaveRecursiveCall();
7488 Py_DECREF(tmp2);
7489 if (res != 0) goto failed;
7490 if (len != PyList_GET_SIZE(tmp)) {
7491 PyErr_SetString(PyExc_RuntimeError, "Try field \"orelse\" changed size during iteration");
7492 goto failed;
7493 }
7494 asdl_seq_SET(orelse, i, val);
7495 }
7496 Py_CLEAR(tmp);
7497 }
7498 if (_PyObject_LookupAttr(obj, state->finalbody, &tmp) < 0) {
7499 return 1;
7500 }
7501 if (tmp == NULL) {
7502 PyErr_SetString(PyExc_TypeError, "required field \"finalbody\" missing from Try");
7503 return 1;
7504 }
7505 else {
7506 int res;
7507 Py_ssize_t len;
7508 Py_ssize_t i;
7509 if (!PyList_Check(tmp)) {
7510 PyErr_Format(PyExc_TypeError, "Try field \"finalbody\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
7511 goto failed;
7512 }
7513 len = PyList_GET_SIZE(tmp);
7514 finalbody = _Py_asdl_stmt_seq_new(len, arena);
7515 if (finalbody == NULL) goto failed;
7516 for (i = 0; i < len; i++) {
7517 stmt_ty val;
7518 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
7519 Py_INCREF(tmp2);
7520 if (_Py_EnterRecursiveCall(" while traversing 'Try' node")) {
7521 goto failed;
7522 }
7523 res = obj2ast_stmt(state, tmp2, &val, arena);
7524 _Py_LeaveRecursiveCall();
7525 Py_DECREF(tmp2);
7526 if (res != 0) goto failed;
7527 if (len != PyList_GET_SIZE(tmp)) {
7528 PyErr_SetString(PyExc_RuntimeError, "Try field \"finalbody\" changed size during iteration");
7529 goto failed;
7530 }
7531 asdl_seq_SET(finalbody, i, val);
7532 }
7533 Py_CLEAR(tmp);
7534 }
7535 *out = _PyAST_Try(body, handlers, orelse, finalbody, lineno,
7536 col_offset, end_lineno, end_col_offset, arena);
7537 if (*out == NULL) goto failed;
7538 return 0;
7539 }
7540 tp = state->TryStar_type;
7541 isinstance = PyObject_IsInstance(obj, tp);
7542 if (isinstance == -1) {
7543 return 1;
7544 }
7545 if (isinstance) {
7546 asdl_stmt_seq* body;
7547 asdl_excepthandler_seq* handlers;
7548 asdl_stmt_seq* orelse;
7549 asdl_stmt_seq* finalbody;
7550
7551 if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
7552 return 1;
7553 }
7554 if (tmp == NULL) {
7555 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from TryStar");
7556 return 1;
7557 }
7558 else {
7559 int res;
7560 Py_ssize_t len;
7561 Py_ssize_t i;
7562 if (!PyList_Check(tmp)) {
7563 PyErr_Format(PyExc_TypeError, "TryStar field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
7564 goto failed;
7565 }
7566 len = PyList_GET_SIZE(tmp);
7567 body = _Py_asdl_stmt_seq_new(len, arena);
7568 if (body == NULL) goto failed;
7569 for (i = 0; i < len; i++) {
7570 stmt_ty val;
7571 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
7572 Py_INCREF(tmp2);
7573 if (_Py_EnterRecursiveCall(" while traversing 'TryStar' node")) {
7574 goto failed;
7575 }
7576 res = obj2ast_stmt(state, tmp2, &val, arena);
7577 _Py_LeaveRecursiveCall();
7578 Py_DECREF(tmp2);
7579 if (res != 0) goto failed;
7580 if (len != PyList_GET_SIZE(tmp)) {
7581 PyErr_SetString(PyExc_RuntimeError, "TryStar field \"body\" changed size during iteration");
7582 goto failed;
7583 }
7584 asdl_seq_SET(body, i, val);
7585 }
7586 Py_CLEAR(tmp);
7587 }
7588 if (_PyObject_LookupAttr(obj, state->handlers, &tmp) < 0) {
7589 return 1;
7590 }
7591 if (tmp == NULL) {
7592 PyErr_SetString(PyExc_TypeError, "required field \"handlers\" missing from TryStar");
7593 return 1;
7594 }
7595 else {
7596 int res;
7597 Py_ssize_t len;
7598 Py_ssize_t i;
7599 if (!PyList_Check(tmp)) {
7600 PyErr_Format(PyExc_TypeError, "TryStar field \"handlers\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
7601 goto failed;
7602 }
7603 len = PyList_GET_SIZE(tmp);
7604 handlers = _Py_asdl_excepthandler_seq_new(len, arena);
7605 if (handlers == NULL) goto failed;
7606 for (i = 0; i < len; i++) {
7607 excepthandler_ty val;
7608 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
7609 Py_INCREF(tmp2);
7610 if (_Py_EnterRecursiveCall(" while traversing 'TryStar' node")) {
7611 goto failed;
7612 }
7613 res = obj2ast_excepthandler(state, tmp2, &val, arena);
7614 _Py_LeaveRecursiveCall();
7615 Py_DECREF(tmp2);
7616 if (res != 0) goto failed;
7617 if (len != PyList_GET_SIZE(tmp)) {
7618 PyErr_SetString(PyExc_RuntimeError, "TryStar field \"handlers\" changed size during iteration");
7619 goto failed;
7620 }
7621 asdl_seq_SET(handlers, i, val);
7622 }
7623 Py_CLEAR(tmp);
7624 }
7625 if (_PyObject_LookupAttr(obj, state->orelse, &tmp) < 0) {
7626 return 1;
7627 }
7628 if (tmp == NULL) {
7629 PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from TryStar");
7630 return 1;
7631 }
7632 else {
7633 int res;
7634 Py_ssize_t len;
7635 Py_ssize_t i;
7636 if (!PyList_Check(tmp)) {
7637 PyErr_Format(PyExc_TypeError, "TryStar field \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
7638 goto failed;
7639 }
7640 len = PyList_GET_SIZE(tmp);
7641 orelse = _Py_asdl_stmt_seq_new(len, arena);
7642 if (orelse == NULL) goto failed;
7643 for (i = 0; i < len; i++) {
7644 stmt_ty val;
7645 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
7646 Py_INCREF(tmp2);
7647 if (_Py_EnterRecursiveCall(" while traversing 'TryStar' node")) {
7648 goto failed;
7649 }
7650 res = obj2ast_stmt(state, tmp2, &val, arena);
7651 _Py_LeaveRecursiveCall();
7652 Py_DECREF(tmp2);
7653 if (res != 0) goto failed;
7654 if (len != PyList_GET_SIZE(tmp)) {
7655 PyErr_SetString(PyExc_RuntimeError, "TryStar field \"orelse\" changed size during iteration");
7656 goto failed;
7657 }
7658 asdl_seq_SET(orelse, i, val);
7659 }
7660 Py_CLEAR(tmp);
7661 }
7662 if (_PyObject_LookupAttr(obj, state->finalbody, &tmp) < 0) {
7663 return 1;
7664 }
7665 if (tmp == NULL) {
7666 PyErr_SetString(PyExc_TypeError, "required field \"finalbody\" missing from TryStar");
7667 return 1;
7668 }
7669 else {
7670 int res;
7671 Py_ssize_t len;
7672 Py_ssize_t i;
7673 if (!PyList_Check(tmp)) {
7674 PyErr_Format(PyExc_TypeError, "TryStar field \"finalbody\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
7675 goto failed;
7676 }
7677 len = PyList_GET_SIZE(tmp);
7678 finalbody = _Py_asdl_stmt_seq_new(len, arena);
7679 if (finalbody == NULL) goto failed;
7680 for (i = 0; i < len; i++) {
7681 stmt_ty val;
7682 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
7683 Py_INCREF(tmp2);
7684 if (_Py_EnterRecursiveCall(" while traversing 'TryStar' node")) {
7685 goto failed;
7686 }
7687 res = obj2ast_stmt(state, tmp2, &val, arena);
7688 _Py_LeaveRecursiveCall();
7689 Py_DECREF(tmp2);
7690 if (res != 0) goto failed;
7691 if (len != PyList_GET_SIZE(tmp)) {
7692 PyErr_SetString(PyExc_RuntimeError, "TryStar field \"finalbody\" changed size during iteration");
7693 goto failed;
7694 }
7695 asdl_seq_SET(finalbody, i, val);
7696 }
7697 Py_CLEAR(tmp);
7698 }
7699 *out = _PyAST_TryStar(body, handlers, orelse, finalbody, lineno,
7700 col_offset, end_lineno, end_col_offset, arena);
7701 if (*out == NULL) goto failed;
7702 return 0;
7703 }
7704 tp = state->Assert_type;
7705 isinstance = PyObject_IsInstance(obj, tp);
7706 if (isinstance == -1) {
7707 return 1;
7708 }
7709 if (isinstance) {
7710 expr_ty test;
7711 expr_ty msg;
7712
7713 if (_PyObject_LookupAttr(obj, state->test, &tmp) < 0) {
7714 return 1;
7715 }
7716 if (tmp == NULL) {
7717 PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from Assert");
7718 return 1;
7719 }
7720 else {
7721 int res;
7722 if (_Py_EnterRecursiveCall(" while traversing 'Assert' node")) {
7723 goto failed;
7724 }
7725 res = obj2ast_expr(state, tmp, &test, arena);
7726 _Py_LeaveRecursiveCall();
7727 if (res != 0) goto failed;
7728 Py_CLEAR(tmp);
7729 }
7730 if (_PyObject_LookupAttr(obj, state->msg, &tmp) < 0) {
7731 return 1;
7732 }
7733 if (tmp == NULL || tmp == Py_None) {
7734 Py_CLEAR(tmp);
7735 msg = NULL;
7736 }
7737 else {
7738 int res;
7739 if (_Py_EnterRecursiveCall(" while traversing 'Assert' node")) {
7740 goto failed;
7741 }
7742 res = obj2ast_expr(state, tmp, &msg, arena);
7743 _Py_LeaveRecursiveCall();
7744 if (res != 0) goto failed;
7745 Py_CLEAR(tmp);
7746 }
7747 *out = _PyAST_Assert(test, msg, lineno, col_offset, end_lineno,
7748 end_col_offset, arena);
7749 if (*out == NULL) goto failed;
7750 return 0;
7751 }
7752 tp = state->Import_type;
7753 isinstance = PyObject_IsInstance(obj, tp);
7754 if (isinstance == -1) {
7755 return 1;
7756 }
7757 if (isinstance) {
7758 asdl_alias_seq* names;
7759
7760 if (_PyObject_LookupAttr(obj, state->names, &tmp) < 0) {
7761 return 1;
7762 }
7763 if (tmp == NULL) {
7764 PyErr_SetString(PyExc_TypeError, "required field \"names\" missing from Import");
7765 return 1;
7766 }
7767 else {
7768 int res;
7769 Py_ssize_t len;
7770 Py_ssize_t i;
7771 if (!PyList_Check(tmp)) {
7772 PyErr_Format(PyExc_TypeError, "Import field \"names\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
7773 goto failed;
7774 }
7775 len = PyList_GET_SIZE(tmp);
7776 names = _Py_asdl_alias_seq_new(len, arena);
7777 if (names == NULL) goto failed;
7778 for (i = 0; i < len; i++) {
7779 alias_ty val;
7780 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
7781 Py_INCREF(tmp2);
7782 if (_Py_EnterRecursiveCall(" while traversing 'Import' node")) {
7783 goto failed;
7784 }
7785 res = obj2ast_alias(state, tmp2, &val, arena);
7786 _Py_LeaveRecursiveCall();
7787 Py_DECREF(tmp2);
7788 if (res != 0) goto failed;
7789 if (len != PyList_GET_SIZE(tmp)) {
7790 PyErr_SetString(PyExc_RuntimeError, "Import field \"names\" changed size during iteration");
7791 goto failed;
7792 }
7793 asdl_seq_SET(names, i, val);
7794 }
7795 Py_CLEAR(tmp);
7796 }
7797 *out = _PyAST_Import(names, lineno, col_offset, end_lineno,
7798 end_col_offset, arena);
7799 if (*out == NULL) goto failed;
7800 return 0;
7801 }
7802 tp = state->ImportFrom_type;
7803 isinstance = PyObject_IsInstance(obj, tp);
7804 if (isinstance == -1) {
7805 return 1;
7806 }
7807 if (isinstance) {
7808 identifier module;
7809 asdl_alias_seq* names;
7810 int level;
7811
7812 if (_PyObject_LookupAttr(obj, state->module, &tmp) < 0) {
7813 return 1;
7814 }
7815 if (tmp == NULL || tmp == Py_None) {
7816 Py_CLEAR(tmp);
7817 module = NULL;
7818 }
7819 else {
7820 int res;
7821 if (_Py_EnterRecursiveCall(" while traversing 'ImportFrom' node")) {
7822 goto failed;
7823 }
7824 res = obj2ast_identifier(state, tmp, &module, arena);
7825 _Py_LeaveRecursiveCall();
7826 if (res != 0) goto failed;
7827 Py_CLEAR(tmp);
7828 }
7829 if (_PyObject_LookupAttr(obj, state->names, &tmp) < 0) {
7830 return 1;
7831 }
7832 if (tmp == NULL) {
7833 PyErr_SetString(PyExc_TypeError, "required field \"names\" missing from ImportFrom");
7834 return 1;
7835 }
7836 else {
7837 int res;
7838 Py_ssize_t len;
7839 Py_ssize_t i;
7840 if (!PyList_Check(tmp)) {
7841 PyErr_Format(PyExc_TypeError, "ImportFrom field \"names\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
7842 goto failed;
7843 }
7844 len = PyList_GET_SIZE(tmp);
7845 names = _Py_asdl_alias_seq_new(len, arena);
7846 if (names == NULL) goto failed;
7847 for (i = 0; i < len; i++) {
7848 alias_ty val;
7849 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
7850 Py_INCREF(tmp2);
7851 if (_Py_EnterRecursiveCall(" while traversing 'ImportFrom' node")) {
7852 goto failed;
7853 }
7854 res = obj2ast_alias(state, tmp2, &val, arena);
7855 _Py_LeaveRecursiveCall();
7856 Py_DECREF(tmp2);
7857 if (res != 0) goto failed;
7858 if (len != PyList_GET_SIZE(tmp)) {
7859 PyErr_SetString(PyExc_RuntimeError, "ImportFrom field \"names\" changed size during iteration");
7860 goto failed;
7861 }
7862 asdl_seq_SET(names, i, val);
7863 }
7864 Py_CLEAR(tmp);
7865 }
7866 if (_PyObject_LookupAttr(obj, state->level, &tmp) < 0) {
7867 return 1;
7868 }
7869 if (tmp == NULL || tmp == Py_None) {
7870 Py_CLEAR(tmp);
7871 level = 0;
7872 }
7873 else {
7874 int res;
7875 if (_Py_EnterRecursiveCall(" while traversing 'ImportFrom' node")) {
7876 goto failed;
7877 }
7878 res = obj2ast_int(state, tmp, &level, arena);
7879 _Py_LeaveRecursiveCall();
7880 if (res != 0) goto failed;
7881 Py_CLEAR(tmp);
7882 }
7883 *out = _PyAST_ImportFrom(module, names, level, lineno, col_offset,
7884 end_lineno, end_col_offset, arena);
7885 if (*out == NULL) goto failed;
7886 return 0;
7887 }
7888 tp = state->Global_type;
7889 isinstance = PyObject_IsInstance(obj, tp);
7890 if (isinstance == -1) {
7891 return 1;
7892 }
7893 if (isinstance) {
7894 asdl_identifier_seq* names;
7895
7896 if (_PyObject_LookupAttr(obj, state->names, &tmp) < 0) {
7897 return 1;
7898 }
7899 if (tmp == NULL) {
7900 PyErr_SetString(PyExc_TypeError, "required field \"names\" missing from Global");
7901 return 1;
7902 }
7903 else {
7904 int res;
7905 Py_ssize_t len;
7906 Py_ssize_t i;
7907 if (!PyList_Check(tmp)) {
7908 PyErr_Format(PyExc_TypeError, "Global field \"names\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
7909 goto failed;
7910 }
7911 len = PyList_GET_SIZE(tmp);
7912 names = _Py_asdl_identifier_seq_new(len, arena);
7913 if (names == NULL) goto failed;
7914 for (i = 0; i < len; i++) {
7915 identifier val;
7916 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
7917 Py_INCREF(tmp2);
7918 if (_Py_EnterRecursiveCall(" while traversing 'Global' node")) {
7919 goto failed;
7920 }
7921 res = obj2ast_identifier(state, tmp2, &val, arena);
7922 _Py_LeaveRecursiveCall();
7923 Py_DECREF(tmp2);
7924 if (res != 0) goto failed;
7925 if (len != PyList_GET_SIZE(tmp)) {
7926 PyErr_SetString(PyExc_RuntimeError, "Global field \"names\" changed size during iteration");
7927 goto failed;
7928 }
7929 asdl_seq_SET(names, i, val);
7930 }
7931 Py_CLEAR(tmp);
7932 }
7933 *out = _PyAST_Global(names, lineno, col_offset, end_lineno,
7934 end_col_offset, arena);
7935 if (*out == NULL) goto failed;
7936 return 0;
7937 }
7938 tp = state->Nonlocal_type;
7939 isinstance = PyObject_IsInstance(obj, tp);
7940 if (isinstance == -1) {
7941 return 1;
7942 }
7943 if (isinstance) {
7944 asdl_identifier_seq* names;
7945
7946 if (_PyObject_LookupAttr(obj, state->names, &tmp) < 0) {
7947 return 1;
7948 }
7949 if (tmp == NULL) {
7950 PyErr_SetString(PyExc_TypeError, "required field \"names\" missing from Nonlocal");
7951 return 1;
7952 }
7953 else {
7954 int res;
7955 Py_ssize_t len;
7956 Py_ssize_t i;
7957 if (!PyList_Check(tmp)) {
7958 PyErr_Format(PyExc_TypeError, "Nonlocal field \"names\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
7959 goto failed;
7960 }
7961 len = PyList_GET_SIZE(tmp);
7962 names = _Py_asdl_identifier_seq_new(len, arena);
7963 if (names == NULL) goto failed;
7964 for (i = 0; i < len; i++) {
7965 identifier val;
7966 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
7967 Py_INCREF(tmp2);
7968 if (_Py_EnterRecursiveCall(" while traversing 'Nonlocal' node")) {
7969 goto failed;
7970 }
7971 res = obj2ast_identifier(state, tmp2, &val, arena);
7972 _Py_LeaveRecursiveCall();
7973 Py_DECREF(tmp2);
7974 if (res != 0) goto failed;
7975 if (len != PyList_GET_SIZE(tmp)) {
7976 PyErr_SetString(PyExc_RuntimeError, "Nonlocal field \"names\" changed size during iteration");
7977 goto failed;
7978 }
7979 asdl_seq_SET(names, i, val);
7980 }
7981 Py_CLEAR(tmp);
7982 }
7983 *out = _PyAST_Nonlocal(names, lineno, col_offset, end_lineno,
7984 end_col_offset, arena);
7985 if (*out == NULL) goto failed;
7986 return 0;
7987 }
7988 tp = state->Expr_type;
7989 isinstance = PyObject_IsInstance(obj, tp);
7990 if (isinstance == -1) {
7991 return 1;
7992 }
7993 if (isinstance) {
7994 expr_ty value;
7995
7996 if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
7997 return 1;
7998 }
7999 if (tmp == NULL) {
8000 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Expr");
8001 return 1;
8002 }
8003 else {
8004 int res;
8005 if (_Py_EnterRecursiveCall(" while traversing 'Expr' node")) {
8006 goto failed;
8007 }
8008 res = obj2ast_expr(state, tmp, &value, arena);
8009 _Py_LeaveRecursiveCall();
8010 if (res != 0) goto failed;
8011 Py_CLEAR(tmp);
8012 }
8013 *out = _PyAST_Expr(value, lineno, col_offset, end_lineno,
8014 end_col_offset, arena);
8015 if (*out == NULL) goto failed;
8016 return 0;
8017 }
8018 tp = state->Pass_type;
8019 isinstance = PyObject_IsInstance(obj, tp);
8020 if (isinstance == -1) {
8021 return 1;
8022 }
8023 if (isinstance) {
8024
8025 *out = _PyAST_Pass(lineno, col_offset, end_lineno, end_col_offset,
8026 arena);
8027 if (*out == NULL) goto failed;
8028 return 0;
8029 }
8030 tp = state->Break_type;
8031 isinstance = PyObject_IsInstance(obj, tp);
8032 if (isinstance == -1) {
8033 return 1;
8034 }
8035 if (isinstance) {
8036
8037 *out = _PyAST_Break(lineno, col_offset, end_lineno, end_col_offset,
8038 arena);
8039 if (*out == NULL) goto failed;
8040 return 0;
8041 }
8042 tp = state->Continue_type;
8043 isinstance = PyObject_IsInstance(obj, tp);
8044 if (isinstance == -1) {
8045 return 1;
8046 }
8047 if (isinstance) {
8048
8049 *out = _PyAST_Continue(lineno, col_offset, end_lineno, end_col_offset,
8050 arena);
8051 if (*out == NULL) goto failed;
8052 return 0;
8053 }
8054
8055 PyErr_Format(PyExc_TypeError, "expected some sort of stmt, but got %R", obj);
8056 failed:
8057 Py_XDECREF(tmp);
8058 return 1;
8059 }
8060
8061 int
8062 obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
8063 arena)
8064 {
8065 int isinstance;
8066
8067 PyObject *tmp = NULL;
8068 PyObject *tp;
8069 int lineno;
8070 int col_offset;
8071 int end_lineno;
8072 int end_col_offset;
8073
8074 if (obj == Py_None) {
8075 *out = NULL;
8076 return 0;
8077 }
8078 if (_PyObject_LookupAttr(obj, state->lineno, &tmp) < 0) {
8079 return 1;
8080 }
8081 if (tmp == NULL) {
8082 PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from expr");
8083 return 1;
8084 }
8085 else {
8086 int res;
8087 if (_Py_EnterRecursiveCall(" while traversing 'expr' node")) {
8088 goto failed;
8089 }
8090 res = obj2ast_int(state, tmp, &lineno, arena);
8091 _Py_LeaveRecursiveCall();
8092 if (res != 0) goto failed;
8093 Py_CLEAR(tmp);
8094 }
8095 if (_PyObject_LookupAttr(obj, state->col_offset, &tmp) < 0) {
8096 return 1;
8097 }
8098 if (tmp == NULL) {
8099 PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from expr");
8100 return 1;
8101 }
8102 else {
8103 int res;
8104 if (_Py_EnterRecursiveCall(" while traversing 'expr' node")) {
8105 goto failed;
8106 }
8107 res = obj2ast_int(state, tmp, &col_offset, arena);
8108 _Py_LeaveRecursiveCall();
8109 if (res != 0) goto failed;
8110 Py_CLEAR(tmp);
8111 }
8112 if (_PyObject_LookupAttr(obj, state->end_lineno, &tmp) < 0) {
8113 return 1;
8114 }
8115 if (tmp == NULL || tmp == Py_None) {
8116 Py_CLEAR(tmp);
8117 end_lineno = lineno;
8118 }
8119 else {
8120 int res;
8121 if (_Py_EnterRecursiveCall(" while traversing 'expr' node")) {
8122 goto failed;
8123 }
8124 res = obj2ast_int(state, tmp, &end_lineno, arena);
8125 _Py_LeaveRecursiveCall();
8126 if (res != 0) goto failed;
8127 Py_CLEAR(tmp);
8128 }
8129 if (_PyObject_LookupAttr(obj, state->end_col_offset, &tmp) < 0) {
8130 return 1;
8131 }
8132 if (tmp == NULL || tmp == Py_None) {
8133 Py_CLEAR(tmp);
8134 end_col_offset = col_offset;
8135 }
8136 else {
8137 int res;
8138 if (_Py_EnterRecursiveCall(" while traversing 'expr' node")) {
8139 goto failed;
8140 }
8141 res = obj2ast_int(state, tmp, &end_col_offset, arena);
8142 _Py_LeaveRecursiveCall();
8143 if (res != 0) goto failed;
8144 Py_CLEAR(tmp);
8145 }
8146 tp = state->BoolOp_type;
8147 isinstance = PyObject_IsInstance(obj, tp);
8148 if (isinstance == -1) {
8149 return 1;
8150 }
8151 if (isinstance) {
8152 boolop_ty op;
8153 asdl_expr_seq* values;
8154
8155 if (_PyObject_LookupAttr(obj, state->op, &tmp) < 0) {
8156 return 1;
8157 }
8158 if (tmp == NULL) {
8159 PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from BoolOp");
8160 return 1;
8161 }
8162 else {
8163 int res;
8164 if (_Py_EnterRecursiveCall(" while traversing 'BoolOp' node")) {
8165 goto failed;
8166 }
8167 res = obj2ast_boolop(state, tmp, &op, arena);
8168 _Py_LeaveRecursiveCall();
8169 if (res != 0) goto failed;
8170 Py_CLEAR(tmp);
8171 }
8172 if (_PyObject_LookupAttr(obj, state->values, &tmp) < 0) {
8173 return 1;
8174 }
8175 if (tmp == NULL) {
8176 PyErr_SetString(PyExc_TypeError, "required field \"values\" missing from BoolOp");
8177 return 1;
8178 }
8179 else {
8180 int res;
8181 Py_ssize_t len;
8182 Py_ssize_t i;
8183 if (!PyList_Check(tmp)) {
8184 PyErr_Format(PyExc_TypeError, "BoolOp field \"values\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
8185 goto failed;
8186 }
8187 len = PyList_GET_SIZE(tmp);
8188 values = _Py_asdl_expr_seq_new(len, arena);
8189 if (values == NULL) goto failed;
8190 for (i = 0; i < len; i++) {
8191 expr_ty val;
8192 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
8193 Py_INCREF(tmp2);
8194 if (_Py_EnterRecursiveCall(" while traversing 'BoolOp' node")) {
8195 goto failed;
8196 }
8197 res = obj2ast_expr(state, tmp2, &val, arena);
8198 _Py_LeaveRecursiveCall();
8199 Py_DECREF(tmp2);
8200 if (res != 0) goto failed;
8201 if (len != PyList_GET_SIZE(tmp)) {
8202 PyErr_SetString(PyExc_RuntimeError, "BoolOp field \"values\" changed size during iteration");
8203 goto failed;
8204 }
8205 asdl_seq_SET(values, i, val);
8206 }
8207 Py_CLEAR(tmp);
8208 }
8209 *out = _PyAST_BoolOp(op, values, lineno, col_offset, end_lineno,
8210 end_col_offset, arena);
8211 if (*out == NULL) goto failed;
8212 return 0;
8213 }
8214 tp = state->NamedExpr_type;
8215 isinstance = PyObject_IsInstance(obj, tp);
8216 if (isinstance == -1) {
8217 return 1;
8218 }
8219 if (isinstance) {
8220 expr_ty target;
8221 expr_ty value;
8222
8223 if (_PyObject_LookupAttr(obj, state->target, &tmp) < 0) {
8224 return 1;
8225 }
8226 if (tmp == NULL) {
8227 PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from NamedExpr");
8228 return 1;
8229 }
8230 else {
8231 int res;
8232 if (_Py_EnterRecursiveCall(" while traversing 'NamedExpr' node")) {
8233 goto failed;
8234 }
8235 res = obj2ast_expr(state, tmp, &target, arena);
8236 _Py_LeaveRecursiveCall();
8237 if (res != 0) goto failed;
8238 Py_CLEAR(tmp);
8239 }
8240 if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
8241 return 1;
8242 }
8243 if (tmp == NULL) {
8244 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from NamedExpr");
8245 return 1;
8246 }
8247 else {
8248 int res;
8249 if (_Py_EnterRecursiveCall(" while traversing 'NamedExpr' node")) {
8250 goto failed;
8251 }
8252 res = obj2ast_expr(state, tmp, &value, arena);
8253 _Py_LeaveRecursiveCall();
8254 if (res != 0) goto failed;
8255 Py_CLEAR(tmp);
8256 }
8257 *out = _PyAST_NamedExpr(target, value, lineno, col_offset, end_lineno,
8258 end_col_offset, arena);
8259 if (*out == NULL) goto failed;
8260 return 0;
8261 }
8262 tp = state->BinOp_type;
8263 isinstance = PyObject_IsInstance(obj, tp);
8264 if (isinstance == -1) {
8265 return 1;
8266 }
8267 if (isinstance) {
8268 expr_ty left;
8269 operator_ty op;
8270 expr_ty right;
8271
8272 if (_PyObject_LookupAttr(obj, state->left, &tmp) < 0) {
8273 return 1;
8274 }
8275 if (tmp == NULL) {
8276 PyErr_SetString(PyExc_TypeError, "required field \"left\" missing from BinOp");
8277 return 1;
8278 }
8279 else {
8280 int res;
8281 if (_Py_EnterRecursiveCall(" while traversing 'BinOp' node")) {
8282 goto failed;
8283 }
8284 res = obj2ast_expr(state, tmp, &left, arena);
8285 _Py_LeaveRecursiveCall();
8286 if (res != 0) goto failed;
8287 Py_CLEAR(tmp);
8288 }
8289 if (_PyObject_LookupAttr(obj, state->op, &tmp) < 0) {
8290 return 1;
8291 }
8292 if (tmp == NULL) {
8293 PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from BinOp");
8294 return 1;
8295 }
8296 else {
8297 int res;
8298 if (_Py_EnterRecursiveCall(" while traversing 'BinOp' node")) {
8299 goto failed;
8300 }
8301 res = obj2ast_operator(state, tmp, &op, arena);
8302 _Py_LeaveRecursiveCall();
8303 if (res != 0) goto failed;
8304 Py_CLEAR(tmp);
8305 }
8306 if (_PyObject_LookupAttr(obj, state->right, &tmp) < 0) {
8307 return 1;
8308 }
8309 if (tmp == NULL) {
8310 PyErr_SetString(PyExc_TypeError, "required field \"right\" missing from BinOp");
8311 return 1;
8312 }
8313 else {
8314 int res;
8315 if (_Py_EnterRecursiveCall(" while traversing 'BinOp' node")) {
8316 goto failed;
8317 }
8318 res = obj2ast_expr(state, tmp, &right, arena);
8319 _Py_LeaveRecursiveCall();
8320 if (res != 0) goto failed;
8321 Py_CLEAR(tmp);
8322 }
8323 *out = _PyAST_BinOp(left, op, right, lineno, col_offset, end_lineno,
8324 end_col_offset, arena);
8325 if (*out == NULL) goto failed;
8326 return 0;
8327 }
8328 tp = state->UnaryOp_type;
8329 isinstance = PyObject_IsInstance(obj, tp);
8330 if (isinstance == -1) {
8331 return 1;
8332 }
8333 if (isinstance) {
8334 unaryop_ty op;
8335 expr_ty operand;
8336
8337 if (_PyObject_LookupAttr(obj, state->op, &tmp) < 0) {
8338 return 1;
8339 }
8340 if (tmp == NULL) {
8341 PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from UnaryOp");
8342 return 1;
8343 }
8344 else {
8345 int res;
8346 if (_Py_EnterRecursiveCall(" while traversing 'UnaryOp' node")) {
8347 goto failed;
8348 }
8349 res = obj2ast_unaryop(state, tmp, &op, arena);
8350 _Py_LeaveRecursiveCall();
8351 if (res != 0) goto failed;
8352 Py_CLEAR(tmp);
8353 }
8354 if (_PyObject_LookupAttr(obj, state->operand, &tmp) < 0) {
8355 return 1;
8356 }
8357 if (tmp == NULL) {
8358 PyErr_SetString(PyExc_TypeError, "required field \"operand\" missing from UnaryOp");
8359 return 1;
8360 }
8361 else {
8362 int res;
8363 if (_Py_EnterRecursiveCall(" while traversing 'UnaryOp' node")) {
8364 goto failed;
8365 }
8366 res = obj2ast_expr(state, tmp, &operand, arena);
8367 _Py_LeaveRecursiveCall();
8368 if (res != 0) goto failed;
8369 Py_CLEAR(tmp);
8370 }
8371 *out = _PyAST_UnaryOp(op, operand, lineno, col_offset, end_lineno,
8372 end_col_offset, arena);
8373 if (*out == NULL) goto failed;
8374 return 0;
8375 }
8376 tp = state->Lambda_type;
8377 isinstance = PyObject_IsInstance(obj, tp);
8378 if (isinstance == -1) {
8379 return 1;
8380 }
8381 if (isinstance) {
8382 arguments_ty args;
8383 expr_ty body;
8384
8385 if (_PyObject_LookupAttr(obj, state->args, &tmp) < 0) {
8386 return 1;
8387 }
8388 if (tmp == NULL) {
8389 PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from Lambda");
8390 return 1;
8391 }
8392 else {
8393 int res;
8394 if (_Py_EnterRecursiveCall(" while traversing 'Lambda' node")) {
8395 goto failed;
8396 }
8397 res = obj2ast_arguments(state, tmp, &args, arena);
8398 _Py_LeaveRecursiveCall();
8399 if (res != 0) goto failed;
8400 Py_CLEAR(tmp);
8401 }
8402 if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
8403 return 1;
8404 }
8405 if (tmp == NULL) {
8406 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Lambda");
8407 return 1;
8408 }
8409 else {
8410 int res;
8411 if (_Py_EnterRecursiveCall(" while traversing 'Lambda' node")) {
8412 goto failed;
8413 }
8414 res = obj2ast_expr(state, tmp, &body, arena);
8415 _Py_LeaveRecursiveCall();
8416 if (res != 0) goto failed;
8417 Py_CLEAR(tmp);
8418 }
8419 *out = _PyAST_Lambda(args, body, lineno, col_offset, end_lineno,
8420 end_col_offset, arena);
8421 if (*out == NULL) goto failed;
8422 return 0;
8423 }
8424 tp = state->IfExp_type;
8425 isinstance = PyObject_IsInstance(obj, tp);
8426 if (isinstance == -1) {
8427 return 1;
8428 }
8429 if (isinstance) {
8430 expr_ty test;
8431 expr_ty body;
8432 expr_ty orelse;
8433
8434 if (_PyObject_LookupAttr(obj, state->test, &tmp) < 0) {
8435 return 1;
8436 }
8437 if (tmp == NULL) {
8438 PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from IfExp");
8439 return 1;
8440 }
8441 else {
8442 int res;
8443 if (_Py_EnterRecursiveCall(" while traversing 'IfExp' node")) {
8444 goto failed;
8445 }
8446 res = obj2ast_expr(state, tmp, &test, arena);
8447 _Py_LeaveRecursiveCall();
8448 if (res != 0) goto failed;
8449 Py_CLEAR(tmp);
8450 }
8451 if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
8452 return 1;
8453 }
8454 if (tmp == NULL) {
8455 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from IfExp");
8456 return 1;
8457 }
8458 else {
8459 int res;
8460 if (_Py_EnterRecursiveCall(" while traversing 'IfExp' node")) {
8461 goto failed;
8462 }
8463 res = obj2ast_expr(state, tmp, &body, arena);
8464 _Py_LeaveRecursiveCall();
8465 if (res != 0) goto failed;
8466 Py_CLEAR(tmp);
8467 }
8468 if (_PyObject_LookupAttr(obj, state->orelse, &tmp) < 0) {
8469 return 1;
8470 }
8471 if (tmp == NULL) {
8472 PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from IfExp");
8473 return 1;
8474 }
8475 else {
8476 int res;
8477 if (_Py_EnterRecursiveCall(" while traversing 'IfExp' node")) {
8478 goto failed;
8479 }
8480 res = obj2ast_expr(state, tmp, &orelse, arena);
8481 _Py_LeaveRecursiveCall();
8482 if (res != 0) goto failed;
8483 Py_CLEAR(tmp);
8484 }
8485 *out = _PyAST_IfExp(test, body, orelse, lineno, col_offset, end_lineno,
8486 end_col_offset, arena);
8487 if (*out == NULL) goto failed;
8488 return 0;
8489 }
8490 tp = state->Dict_type;
8491 isinstance = PyObject_IsInstance(obj, tp);
8492 if (isinstance == -1) {
8493 return 1;
8494 }
8495 if (isinstance) {
8496 asdl_expr_seq* keys;
8497 asdl_expr_seq* values;
8498
8499 if (_PyObject_LookupAttr(obj, state->keys, &tmp) < 0) {
8500 return 1;
8501 }
8502 if (tmp == NULL) {
8503 PyErr_SetString(PyExc_TypeError, "required field \"keys\" missing from Dict");
8504 return 1;
8505 }
8506 else {
8507 int res;
8508 Py_ssize_t len;
8509 Py_ssize_t i;
8510 if (!PyList_Check(tmp)) {
8511 PyErr_Format(PyExc_TypeError, "Dict field \"keys\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
8512 goto failed;
8513 }
8514 len = PyList_GET_SIZE(tmp);
8515 keys = _Py_asdl_expr_seq_new(len, arena);
8516 if (keys == NULL) goto failed;
8517 for (i = 0; i < len; i++) {
8518 expr_ty val;
8519 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
8520 Py_INCREF(tmp2);
8521 if (_Py_EnterRecursiveCall(" while traversing 'Dict' node")) {
8522 goto failed;
8523 }
8524 res = obj2ast_expr(state, tmp2, &val, arena);
8525 _Py_LeaveRecursiveCall();
8526 Py_DECREF(tmp2);
8527 if (res != 0) goto failed;
8528 if (len != PyList_GET_SIZE(tmp)) {
8529 PyErr_SetString(PyExc_RuntimeError, "Dict field \"keys\" changed size during iteration");
8530 goto failed;
8531 }
8532 asdl_seq_SET(keys, i, val);
8533 }
8534 Py_CLEAR(tmp);
8535 }
8536 if (_PyObject_LookupAttr(obj, state->values, &tmp) < 0) {
8537 return 1;
8538 }
8539 if (tmp == NULL) {
8540 PyErr_SetString(PyExc_TypeError, "required field \"values\" missing from Dict");
8541 return 1;
8542 }
8543 else {
8544 int res;
8545 Py_ssize_t len;
8546 Py_ssize_t i;
8547 if (!PyList_Check(tmp)) {
8548 PyErr_Format(PyExc_TypeError, "Dict field \"values\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
8549 goto failed;
8550 }
8551 len = PyList_GET_SIZE(tmp);
8552 values = _Py_asdl_expr_seq_new(len, arena);
8553 if (values == NULL) goto failed;
8554 for (i = 0; i < len; i++) {
8555 expr_ty val;
8556 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
8557 Py_INCREF(tmp2);
8558 if (_Py_EnterRecursiveCall(" while traversing 'Dict' node")) {
8559 goto failed;
8560 }
8561 res = obj2ast_expr(state, tmp2, &val, arena);
8562 _Py_LeaveRecursiveCall();
8563 Py_DECREF(tmp2);
8564 if (res != 0) goto failed;
8565 if (len != PyList_GET_SIZE(tmp)) {
8566 PyErr_SetString(PyExc_RuntimeError, "Dict field \"values\" changed size during iteration");
8567 goto failed;
8568 }
8569 asdl_seq_SET(values, i, val);
8570 }
8571 Py_CLEAR(tmp);
8572 }
8573 *out = _PyAST_Dict(keys, values, lineno, col_offset, end_lineno,
8574 end_col_offset, arena);
8575 if (*out == NULL) goto failed;
8576 return 0;
8577 }
8578 tp = state->Set_type;
8579 isinstance = PyObject_IsInstance(obj, tp);
8580 if (isinstance == -1) {
8581 return 1;
8582 }
8583 if (isinstance) {
8584 asdl_expr_seq* elts;
8585
8586 if (_PyObject_LookupAttr(obj, state->elts, &tmp) < 0) {
8587 return 1;
8588 }
8589 if (tmp == NULL) {
8590 PyErr_SetString(PyExc_TypeError, "required field \"elts\" missing from Set");
8591 return 1;
8592 }
8593 else {
8594 int res;
8595 Py_ssize_t len;
8596 Py_ssize_t i;
8597 if (!PyList_Check(tmp)) {
8598 PyErr_Format(PyExc_TypeError, "Set field \"elts\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
8599 goto failed;
8600 }
8601 len = PyList_GET_SIZE(tmp);
8602 elts = _Py_asdl_expr_seq_new(len, arena);
8603 if (elts == NULL) goto failed;
8604 for (i = 0; i < len; i++) {
8605 expr_ty val;
8606 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
8607 Py_INCREF(tmp2);
8608 if (_Py_EnterRecursiveCall(" while traversing 'Set' node")) {
8609 goto failed;
8610 }
8611 res = obj2ast_expr(state, tmp2, &val, arena);
8612 _Py_LeaveRecursiveCall();
8613 Py_DECREF(tmp2);
8614 if (res != 0) goto failed;
8615 if (len != PyList_GET_SIZE(tmp)) {
8616 PyErr_SetString(PyExc_RuntimeError, "Set field \"elts\" changed size during iteration");
8617 goto failed;
8618 }
8619 asdl_seq_SET(elts, i, val);
8620 }
8621 Py_CLEAR(tmp);
8622 }
8623 *out = _PyAST_Set(elts, lineno, col_offset, end_lineno, end_col_offset,
8624 arena);
8625 if (*out == NULL) goto failed;
8626 return 0;
8627 }
8628 tp = state->ListComp_type;
8629 isinstance = PyObject_IsInstance(obj, tp);
8630 if (isinstance == -1) {
8631 return 1;
8632 }
8633 if (isinstance) {
8634 expr_ty elt;
8635 asdl_comprehension_seq* generators;
8636
8637 if (_PyObject_LookupAttr(obj, state->elt, &tmp) < 0) {
8638 return 1;
8639 }
8640 if (tmp == NULL) {
8641 PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from ListComp");
8642 return 1;
8643 }
8644 else {
8645 int res;
8646 if (_Py_EnterRecursiveCall(" while traversing 'ListComp' node")) {
8647 goto failed;
8648 }
8649 res = obj2ast_expr(state, tmp, &elt, arena);
8650 _Py_LeaveRecursiveCall();
8651 if (res != 0) goto failed;
8652 Py_CLEAR(tmp);
8653 }
8654 if (_PyObject_LookupAttr(obj, state->generators, &tmp) < 0) {
8655 return 1;
8656 }
8657 if (tmp == NULL) {
8658 PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from ListComp");
8659 return 1;
8660 }
8661 else {
8662 int res;
8663 Py_ssize_t len;
8664 Py_ssize_t i;
8665 if (!PyList_Check(tmp)) {
8666 PyErr_Format(PyExc_TypeError, "ListComp field \"generators\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
8667 goto failed;
8668 }
8669 len = PyList_GET_SIZE(tmp);
8670 generators = _Py_asdl_comprehension_seq_new(len, arena);
8671 if (generators == NULL) goto failed;
8672 for (i = 0; i < len; i++) {
8673 comprehension_ty val;
8674 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
8675 Py_INCREF(tmp2);
8676 if (_Py_EnterRecursiveCall(" while traversing 'ListComp' node")) {
8677 goto failed;
8678 }
8679 res = obj2ast_comprehension(state, tmp2, &val, arena);
8680 _Py_LeaveRecursiveCall();
8681 Py_DECREF(tmp2);
8682 if (res != 0) goto failed;
8683 if (len != PyList_GET_SIZE(tmp)) {
8684 PyErr_SetString(PyExc_RuntimeError, "ListComp field \"generators\" changed size during iteration");
8685 goto failed;
8686 }
8687 asdl_seq_SET(generators, i, val);
8688 }
8689 Py_CLEAR(tmp);
8690 }
8691 *out = _PyAST_ListComp(elt, generators, lineno, col_offset, end_lineno,
8692 end_col_offset, arena);
8693 if (*out == NULL) goto failed;
8694 return 0;
8695 }
8696 tp = state->SetComp_type;
8697 isinstance = PyObject_IsInstance(obj, tp);
8698 if (isinstance == -1) {
8699 return 1;
8700 }
8701 if (isinstance) {
8702 expr_ty elt;
8703 asdl_comprehension_seq* generators;
8704
8705 if (_PyObject_LookupAttr(obj, state->elt, &tmp) < 0) {
8706 return 1;
8707 }
8708 if (tmp == NULL) {
8709 PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from SetComp");
8710 return 1;
8711 }
8712 else {
8713 int res;
8714 if (_Py_EnterRecursiveCall(" while traversing 'SetComp' node")) {
8715 goto failed;
8716 }
8717 res = obj2ast_expr(state, tmp, &elt, arena);
8718 _Py_LeaveRecursiveCall();
8719 if (res != 0) goto failed;
8720 Py_CLEAR(tmp);
8721 }
8722 if (_PyObject_LookupAttr(obj, state->generators, &tmp) < 0) {
8723 return 1;
8724 }
8725 if (tmp == NULL) {
8726 PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from SetComp");
8727 return 1;
8728 }
8729 else {
8730 int res;
8731 Py_ssize_t len;
8732 Py_ssize_t i;
8733 if (!PyList_Check(tmp)) {
8734 PyErr_Format(PyExc_TypeError, "SetComp field \"generators\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
8735 goto failed;
8736 }
8737 len = PyList_GET_SIZE(tmp);
8738 generators = _Py_asdl_comprehension_seq_new(len, arena);
8739 if (generators == NULL) goto failed;
8740 for (i = 0; i < len; i++) {
8741 comprehension_ty val;
8742 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
8743 Py_INCREF(tmp2);
8744 if (_Py_EnterRecursiveCall(" while traversing 'SetComp' node")) {
8745 goto failed;
8746 }
8747 res = obj2ast_comprehension(state, tmp2, &val, arena);
8748 _Py_LeaveRecursiveCall();
8749 Py_DECREF(tmp2);
8750 if (res != 0) goto failed;
8751 if (len != PyList_GET_SIZE(tmp)) {
8752 PyErr_SetString(PyExc_RuntimeError, "SetComp field \"generators\" changed size during iteration");
8753 goto failed;
8754 }
8755 asdl_seq_SET(generators, i, val);
8756 }
8757 Py_CLEAR(tmp);
8758 }
8759 *out = _PyAST_SetComp(elt, generators, lineno, col_offset, end_lineno,
8760 end_col_offset, arena);
8761 if (*out == NULL) goto failed;
8762 return 0;
8763 }
8764 tp = state->DictComp_type;
8765 isinstance = PyObject_IsInstance(obj, tp);
8766 if (isinstance == -1) {
8767 return 1;
8768 }
8769 if (isinstance) {
8770 expr_ty key;
8771 expr_ty value;
8772 asdl_comprehension_seq* generators;
8773
8774 if (_PyObject_LookupAttr(obj, state->key, &tmp) < 0) {
8775 return 1;
8776 }
8777 if (tmp == NULL) {
8778 PyErr_SetString(PyExc_TypeError, "required field \"key\" missing from DictComp");
8779 return 1;
8780 }
8781 else {
8782 int res;
8783 if (_Py_EnterRecursiveCall(" while traversing 'DictComp' node")) {
8784 goto failed;
8785 }
8786 res = obj2ast_expr(state, tmp, &key, arena);
8787 _Py_LeaveRecursiveCall();
8788 if (res != 0) goto failed;
8789 Py_CLEAR(tmp);
8790 }
8791 if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
8792 return 1;
8793 }
8794 if (tmp == NULL) {
8795 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from DictComp");
8796 return 1;
8797 }
8798 else {
8799 int res;
8800 if (_Py_EnterRecursiveCall(" while traversing 'DictComp' node")) {
8801 goto failed;
8802 }
8803 res = obj2ast_expr(state, tmp, &value, arena);
8804 _Py_LeaveRecursiveCall();
8805 if (res != 0) goto failed;
8806 Py_CLEAR(tmp);
8807 }
8808 if (_PyObject_LookupAttr(obj, state->generators, &tmp) < 0) {
8809 return 1;
8810 }
8811 if (tmp == NULL) {
8812 PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from DictComp");
8813 return 1;
8814 }
8815 else {
8816 int res;
8817 Py_ssize_t len;
8818 Py_ssize_t i;
8819 if (!PyList_Check(tmp)) {
8820 PyErr_Format(PyExc_TypeError, "DictComp field \"generators\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
8821 goto failed;
8822 }
8823 len = PyList_GET_SIZE(tmp);
8824 generators = _Py_asdl_comprehension_seq_new(len, arena);
8825 if (generators == NULL) goto failed;
8826 for (i = 0; i < len; i++) {
8827 comprehension_ty val;
8828 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
8829 Py_INCREF(tmp2);
8830 if (_Py_EnterRecursiveCall(" while traversing 'DictComp' node")) {
8831 goto failed;
8832 }
8833 res = obj2ast_comprehension(state, tmp2, &val, arena);
8834 _Py_LeaveRecursiveCall();
8835 Py_DECREF(tmp2);
8836 if (res != 0) goto failed;
8837 if (len != PyList_GET_SIZE(tmp)) {
8838 PyErr_SetString(PyExc_RuntimeError, "DictComp field \"generators\" changed size during iteration");
8839 goto failed;
8840 }
8841 asdl_seq_SET(generators, i, val);
8842 }
8843 Py_CLEAR(tmp);
8844 }
8845 *out = _PyAST_DictComp(key, value, generators, lineno, col_offset,
8846 end_lineno, end_col_offset, arena);
8847 if (*out == NULL) goto failed;
8848 return 0;
8849 }
8850 tp = state->GeneratorExp_type;
8851 isinstance = PyObject_IsInstance(obj, tp);
8852 if (isinstance == -1) {
8853 return 1;
8854 }
8855 if (isinstance) {
8856 expr_ty elt;
8857 asdl_comprehension_seq* generators;
8858
8859 if (_PyObject_LookupAttr(obj, state->elt, &tmp) < 0) {
8860 return 1;
8861 }
8862 if (tmp == NULL) {
8863 PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from GeneratorExp");
8864 return 1;
8865 }
8866 else {
8867 int res;
8868 if (_Py_EnterRecursiveCall(" while traversing 'GeneratorExp' node")) {
8869 goto failed;
8870 }
8871 res = obj2ast_expr(state, tmp, &elt, arena);
8872 _Py_LeaveRecursiveCall();
8873 if (res != 0) goto failed;
8874 Py_CLEAR(tmp);
8875 }
8876 if (_PyObject_LookupAttr(obj, state->generators, &tmp) < 0) {
8877 return 1;
8878 }
8879 if (tmp == NULL) {
8880 PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from GeneratorExp");
8881 return 1;
8882 }
8883 else {
8884 int res;
8885 Py_ssize_t len;
8886 Py_ssize_t i;
8887 if (!PyList_Check(tmp)) {
8888 PyErr_Format(PyExc_TypeError, "GeneratorExp field \"generators\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
8889 goto failed;
8890 }
8891 len = PyList_GET_SIZE(tmp);
8892 generators = _Py_asdl_comprehension_seq_new(len, arena);
8893 if (generators == NULL) goto failed;
8894 for (i = 0; i < len; i++) {
8895 comprehension_ty val;
8896 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
8897 Py_INCREF(tmp2);
8898 if (_Py_EnterRecursiveCall(" while traversing 'GeneratorExp' node")) {
8899 goto failed;
8900 }
8901 res = obj2ast_comprehension(state, tmp2, &val, arena);
8902 _Py_LeaveRecursiveCall();
8903 Py_DECREF(tmp2);
8904 if (res != 0) goto failed;
8905 if (len != PyList_GET_SIZE(tmp)) {
8906 PyErr_SetString(PyExc_RuntimeError, "GeneratorExp field \"generators\" changed size during iteration");
8907 goto failed;
8908 }
8909 asdl_seq_SET(generators, i, val);
8910 }
8911 Py_CLEAR(tmp);
8912 }
8913 *out = _PyAST_GeneratorExp(elt, generators, lineno, col_offset,
8914 end_lineno, end_col_offset, arena);
8915 if (*out == NULL) goto failed;
8916 return 0;
8917 }
8918 tp = state->Await_type;
8919 isinstance = PyObject_IsInstance(obj, tp);
8920 if (isinstance == -1) {
8921 return 1;
8922 }
8923 if (isinstance) {
8924 expr_ty value;
8925
8926 if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
8927 return 1;
8928 }
8929 if (tmp == NULL) {
8930 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Await");
8931 return 1;
8932 }
8933 else {
8934 int res;
8935 if (_Py_EnterRecursiveCall(" while traversing 'Await' node")) {
8936 goto failed;
8937 }
8938 res = obj2ast_expr(state, tmp, &value, arena);
8939 _Py_LeaveRecursiveCall();
8940 if (res != 0) goto failed;
8941 Py_CLEAR(tmp);
8942 }
8943 *out = _PyAST_Await(value, lineno, col_offset, end_lineno,
8944 end_col_offset, arena);
8945 if (*out == NULL) goto failed;
8946 return 0;
8947 }
8948 tp = state->Yield_type;
8949 isinstance = PyObject_IsInstance(obj, tp);
8950 if (isinstance == -1) {
8951 return 1;
8952 }
8953 if (isinstance) {
8954 expr_ty value;
8955
8956 if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
8957 return 1;
8958 }
8959 if (tmp == NULL || tmp == Py_None) {
8960 Py_CLEAR(tmp);
8961 value = NULL;
8962 }
8963 else {
8964 int res;
8965 if (_Py_EnterRecursiveCall(" while traversing 'Yield' node")) {
8966 goto failed;
8967 }
8968 res = obj2ast_expr(state, tmp, &value, arena);
8969 _Py_LeaveRecursiveCall();
8970 if (res != 0) goto failed;
8971 Py_CLEAR(tmp);
8972 }
8973 *out = _PyAST_Yield(value, lineno, col_offset, end_lineno,
8974 end_col_offset, arena);
8975 if (*out == NULL) goto failed;
8976 return 0;
8977 }
8978 tp = state->YieldFrom_type;
8979 isinstance = PyObject_IsInstance(obj, tp);
8980 if (isinstance == -1) {
8981 return 1;
8982 }
8983 if (isinstance) {
8984 expr_ty value;
8985
8986 if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
8987 return 1;
8988 }
8989 if (tmp == NULL) {
8990 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from YieldFrom");
8991 return 1;
8992 }
8993 else {
8994 int res;
8995 if (_Py_EnterRecursiveCall(" while traversing 'YieldFrom' node")) {
8996 goto failed;
8997 }
8998 res = obj2ast_expr(state, tmp, &value, arena);
8999 _Py_LeaveRecursiveCall();
9000 if (res != 0) goto failed;
9001 Py_CLEAR(tmp);
9002 }
9003 *out = _PyAST_YieldFrom(value, lineno, col_offset, end_lineno,
9004 end_col_offset, arena);
9005 if (*out == NULL) goto failed;
9006 return 0;
9007 }
9008 tp = state->Compare_type;
9009 isinstance = PyObject_IsInstance(obj, tp);
9010 if (isinstance == -1) {
9011 return 1;
9012 }
9013 if (isinstance) {
9014 expr_ty left;
9015 asdl_int_seq* ops;
9016 asdl_expr_seq* comparators;
9017
9018 if (_PyObject_LookupAttr(obj, state->left, &tmp) < 0) {
9019 return 1;
9020 }
9021 if (tmp == NULL) {
9022 PyErr_SetString(PyExc_TypeError, "required field \"left\" missing from Compare");
9023 return 1;
9024 }
9025 else {
9026 int res;
9027 if (_Py_EnterRecursiveCall(" while traversing 'Compare' node")) {
9028 goto failed;
9029 }
9030 res = obj2ast_expr(state, tmp, &left, arena);
9031 _Py_LeaveRecursiveCall();
9032 if (res != 0) goto failed;
9033 Py_CLEAR(tmp);
9034 }
9035 if (_PyObject_LookupAttr(obj, state->ops, &tmp) < 0) {
9036 return 1;
9037 }
9038 if (tmp == NULL) {
9039 PyErr_SetString(PyExc_TypeError, "required field \"ops\" missing from Compare");
9040 return 1;
9041 }
9042 else {
9043 int res;
9044 Py_ssize_t len;
9045 Py_ssize_t i;
9046 if (!PyList_Check(tmp)) {
9047 PyErr_Format(PyExc_TypeError, "Compare field \"ops\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
9048 goto failed;
9049 }
9050 len = PyList_GET_SIZE(tmp);
9051 ops = _Py_asdl_int_seq_new(len, arena);
9052 if (ops == NULL) goto failed;
9053 for (i = 0; i < len; i++) {
9054 cmpop_ty val;
9055 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
9056 Py_INCREF(tmp2);
9057 if (_Py_EnterRecursiveCall(" while traversing 'Compare' node")) {
9058 goto failed;
9059 }
9060 res = obj2ast_cmpop(state, tmp2, &val, arena);
9061 _Py_LeaveRecursiveCall();
9062 Py_DECREF(tmp2);
9063 if (res != 0) goto failed;
9064 if (len != PyList_GET_SIZE(tmp)) {
9065 PyErr_SetString(PyExc_RuntimeError, "Compare field \"ops\" changed size during iteration");
9066 goto failed;
9067 }
9068 asdl_seq_SET(ops, i, val);
9069 }
9070 Py_CLEAR(tmp);
9071 }
9072 if (_PyObject_LookupAttr(obj, state->comparators, &tmp) < 0) {
9073 return 1;
9074 }
9075 if (tmp == NULL) {
9076 PyErr_SetString(PyExc_TypeError, "required field \"comparators\" missing from Compare");
9077 return 1;
9078 }
9079 else {
9080 int res;
9081 Py_ssize_t len;
9082 Py_ssize_t i;
9083 if (!PyList_Check(tmp)) {
9084 PyErr_Format(PyExc_TypeError, "Compare field \"comparators\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
9085 goto failed;
9086 }
9087 len = PyList_GET_SIZE(tmp);
9088 comparators = _Py_asdl_expr_seq_new(len, arena);
9089 if (comparators == NULL) goto failed;
9090 for (i = 0; i < len; i++) {
9091 expr_ty val;
9092 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
9093 Py_INCREF(tmp2);
9094 if (_Py_EnterRecursiveCall(" while traversing 'Compare' node")) {
9095 goto failed;
9096 }
9097 res = obj2ast_expr(state, tmp2, &val, arena);
9098 _Py_LeaveRecursiveCall();
9099 Py_DECREF(tmp2);
9100 if (res != 0) goto failed;
9101 if (len != PyList_GET_SIZE(tmp)) {
9102 PyErr_SetString(PyExc_RuntimeError, "Compare field \"comparators\" changed size during iteration");
9103 goto failed;
9104 }
9105 asdl_seq_SET(comparators, i, val);
9106 }
9107 Py_CLEAR(tmp);
9108 }
9109 *out = _PyAST_Compare(left, ops, comparators, lineno, col_offset,
9110 end_lineno, end_col_offset, arena);
9111 if (*out == NULL) goto failed;
9112 return 0;
9113 }
9114 tp = state->Call_type;
9115 isinstance = PyObject_IsInstance(obj, tp);
9116 if (isinstance == -1) {
9117 return 1;
9118 }
9119 if (isinstance) {
9120 expr_ty func;
9121 asdl_expr_seq* args;
9122 asdl_keyword_seq* keywords;
9123
9124 if (_PyObject_LookupAttr(obj, state->func, &tmp) < 0) {
9125 return 1;
9126 }
9127 if (tmp == NULL) {
9128 PyErr_SetString(PyExc_TypeError, "required field \"func\" missing from Call");
9129 return 1;
9130 }
9131 else {
9132 int res;
9133 if (_Py_EnterRecursiveCall(" while traversing 'Call' node")) {
9134 goto failed;
9135 }
9136 res = obj2ast_expr(state, tmp, &func, arena);
9137 _Py_LeaveRecursiveCall();
9138 if (res != 0) goto failed;
9139 Py_CLEAR(tmp);
9140 }
9141 if (_PyObject_LookupAttr(obj, state->args, &tmp) < 0) {
9142 return 1;
9143 }
9144 if (tmp == NULL) {
9145 PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from Call");
9146 return 1;
9147 }
9148 else {
9149 int res;
9150 Py_ssize_t len;
9151 Py_ssize_t i;
9152 if (!PyList_Check(tmp)) {
9153 PyErr_Format(PyExc_TypeError, "Call field \"args\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
9154 goto failed;
9155 }
9156 len = PyList_GET_SIZE(tmp);
9157 args = _Py_asdl_expr_seq_new(len, arena);
9158 if (args == NULL) goto failed;
9159 for (i = 0; i < len; i++) {
9160 expr_ty val;
9161 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
9162 Py_INCREF(tmp2);
9163 if (_Py_EnterRecursiveCall(" while traversing 'Call' node")) {
9164 goto failed;
9165 }
9166 res = obj2ast_expr(state, tmp2, &val, arena);
9167 _Py_LeaveRecursiveCall();
9168 Py_DECREF(tmp2);
9169 if (res != 0) goto failed;
9170 if (len != PyList_GET_SIZE(tmp)) {
9171 PyErr_SetString(PyExc_RuntimeError, "Call field \"args\" changed size during iteration");
9172 goto failed;
9173 }
9174 asdl_seq_SET(args, i, val);
9175 }
9176 Py_CLEAR(tmp);
9177 }
9178 if (_PyObject_LookupAttr(obj, state->keywords, &tmp) < 0) {
9179 return 1;
9180 }
9181 if (tmp == NULL) {
9182 PyErr_SetString(PyExc_TypeError, "required field \"keywords\" missing from Call");
9183 return 1;
9184 }
9185 else {
9186 int res;
9187 Py_ssize_t len;
9188 Py_ssize_t i;
9189 if (!PyList_Check(tmp)) {
9190 PyErr_Format(PyExc_TypeError, "Call field \"keywords\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
9191 goto failed;
9192 }
9193 len = PyList_GET_SIZE(tmp);
9194 keywords = _Py_asdl_keyword_seq_new(len, arena);
9195 if (keywords == NULL) goto failed;
9196 for (i = 0; i < len; i++) {
9197 keyword_ty val;
9198 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
9199 Py_INCREF(tmp2);
9200 if (_Py_EnterRecursiveCall(" while traversing 'Call' node")) {
9201 goto failed;
9202 }
9203 res = obj2ast_keyword(state, tmp2, &val, arena);
9204 _Py_LeaveRecursiveCall();
9205 Py_DECREF(tmp2);
9206 if (res != 0) goto failed;
9207 if (len != PyList_GET_SIZE(tmp)) {
9208 PyErr_SetString(PyExc_RuntimeError, "Call field \"keywords\" changed size during iteration");
9209 goto failed;
9210 }
9211 asdl_seq_SET(keywords, i, val);
9212 }
9213 Py_CLEAR(tmp);
9214 }
9215 *out = _PyAST_Call(func, args, keywords, lineno, col_offset,
9216 end_lineno, end_col_offset, arena);
9217 if (*out == NULL) goto failed;
9218 return 0;
9219 }
9220 tp = state->FormattedValue_type;
9221 isinstance = PyObject_IsInstance(obj, tp);
9222 if (isinstance == -1) {
9223 return 1;
9224 }
9225 if (isinstance) {
9226 expr_ty value;
9227 int conversion;
9228 expr_ty format_spec;
9229
9230 if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
9231 return 1;
9232 }
9233 if (tmp == NULL) {
9234 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from FormattedValue");
9235 return 1;
9236 }
9237 else {
9238 int res;
9239 if (_Py_EnterRecursiveCall(" while traversing 'FormattedValue' node")) {
9240 goto failed;
9241 }
9242 res = obj2ast_expr(state, tmp, &value, arena);
9243 _Py_LeaveRecursiveCall();
9244 if (res != 0) goto failed;
9245 Py_CLEAR(tmp);
9246 }
9247 if (_PyObject_LookupAttr(obj, state->conversion, &tmp) < 0) {
9248 return 1;
9249 }
9250 if (tmp == NULL) {
9251 PyErr_SetString(PyExc_TypeError, "required field \"conversion\" missing from FormattedValue");
9252 return 1;
9253 }
9254 else {
9255 int res;
9256 if (_Py_EnterRecursiveCall(" while traversing 'FormattedValue' node")) {
9257 goto failed;
9258 }
9259 res = obj2ast_int(state, tmp, &conversion, arena);
9260 _Py_LeaveRecursiveCall();
9261 if (res != 0) goto failed;
9262 Py_CLEAR(tmp);
9263 }
9264 if (_PyObject_LookupAttr(obj, state->format_spec, &tmp) < 0) {
9265 return 1;
9266 }
9267 if (tmp == NULL || tmp == Py_None) {
9268 Py_CLEAR(tmp);
9269 format_spec = NULL;
9270 }
9271 else {
9272 int res;
9273 if (_Py_EnterRecursiveCall(" while traversing 'FormattedValue' node")) {
9274 goto failed;
9275 }
9276 res = obj2ast_expr(state, tmp, &format_spec, arena);
9277 _Py_LeaveRecursiveCall();
9278 if (res != 0) goto failed;
9279 Py_CLEAR(tmp);
9280 }
9281 *out = _PyAST_FormattedValue(value, conversion, format_spec, lineno,
9282 col_offset, end_lineno, end_col_offset,
9283 arena);
9284 if (*out == NULL) goto failed;
9285 return 0;
9286 }
9287 tp = state->JoinedStr_type;
9288 isinstance = PyObject_IsInstance(obj, tp);
9289 if (isinstance == -1) {
9290 return 1;
9291 }
9292 if (isinstance) {
9293 asdl_expr_seq* values;
9294
9295 if (_PyObject_LookupAttr(obj, state->values, &tmp) < 0) {
9296 return 1;
9297 }
9298 if (tmp == NULL) {
9299 PyErr_SetString(PyExc_TypeError, "required field \"values\" missing from JoinedStr");
9300 return 1;
9301 }
9302 else {
9303 int res;
9304 Py_ssize_t len;
9305 Py_ssize_t i;
9306 if (!PyList_Check(tmp)) {
9307 PyErr_Format(PyExc_TypeError, "JoinedStr field \"values\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
9308 goto failed;
9309 }
9310 len = PyList_GET_SIZE(tmp);
9311 values = _Py_asdl_expr_seq_new(len, arena);
9312 if (values == NULL) goto failed;
9313 for (i = 0; i < len; i++) {
9314 expr_ty val;
9315 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
9316 Py_INCREF(tmp2);
9317 if (_Py_EnterRecursiveCall(" while traversing 'JoinedStr' node")) {
9318 goto failed;
9319 }
9320 res = obj2ast_expr(state, tmp2, &val, arena);
9321 _Py_LeaveRecursiveCall();
9322 Py_DECREF(tmp2);
9323 if (res != 0) goto failed;
9324 if (len != PyList_GET_SIZE(tmp)) {
9325 PyErr_SetString(PyExc_RuntimeError, "JoinedStr field \"values\" changed size during iteration");
9326 goto failed;
9327 }
9328 asdl_seq_SET(values, i, val);
9329 }
9330 Py_CLEAR(tmp);
9331 }
9332 *out = _PyAST_JoinedStr(values, lineno, col_offset, end_lineno,
9333 end_col_offset, arena);
9334 if (*out == NULL) goto failed;
9335 return 0;
9336 }
9337 tp = state->Constant_type;
9338 isinstance = PyObject_IsInstance(obj, tp);
9339 if (isinstance == -1) {
9340 return 1;
9341 }
9342 if (isinstance) {
9343 constant value;
9344 string kind;
9345
9346 if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
9347 return 1;
9348 }
9349 if (tmp == NULL) {
9350 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Constant");
9351 return 1;
9352 }
9353 else {
9354 int res;
9355 if (_Py_EnterRecursiveCall(" while traversing 'Constant' node")) {
9356 goto failed;
9357 }
9358 res = obj2ast_constant(state, tmp, &value, arena);
9359 _Py_LeaveRecursiveCall();
9360 if (res != 0) goto failed;
9361 Py_CLEAR(tmp);
9362 }
9363 if (_PyObject_LookupAttr(obj, state->kind, &tmp) < 0) {
9364 return 1;
9365 }
9366 if (tmp == NULL || tmp == Py_None) {
9367 Py_CLEAR(tmp);
9368 kind = NULL;
9369 }
9370 else {
9371 int res;
9372 if (_Py_EnterRecursiveCall(" while traversing 'Constant' node")) {
9373 goto failed;
9374 }
9375 res = obj2ast_string(state, tmp, &kind, arena);
9376 _Py_LeaveRecursiveCall();
9377 if (res != 0) goto failed;
9378 Py_CLEAR(tmp);
9379 }
9380 *out = _PyAST_Constant(value, kind, lineno, col_offset, end_lineno,
9381 end_col_offset, arena);
9382 if (*out == NULL) goto failed;
9383 return 0;
9384 }
9385 tp = state->Attribute_type;
9386 isinstance = PyObject_IsInstance(obj, tp);
9387 if (isinstance == -1) {
9388 return 1;
9389 }
9390 if (isinstance) {
9391 expr_ty value;
9392 identifier attr;
9393 expr_context_ty ctx;
9394
9395 if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
9396 return 1;
9397 }
9398 if (tmp == NULL) {
9399 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Attribute");
9400 return 1;
9401 }
9402 else {
9403 int res;
9404 if (_Py_EnterRecursiveCall(" while traversing 'Attribute' node")) {
9405 goto failed;
9406 }
9407 res = obj2ast_expr(state, tmp, &value, arena);
9408 _Py_LeaveRecursiveCall();
9409 if (res != 0) goto failed;
9410 Py_CLEAR(tmp);
9411 }
9412 if (_PyObject_LookupAttr(obj, state->attr, &tmp) < 0) {
9413 return 1;
9414 }
9415 if (tmp == NULL) {
9416 PyErr_SetString(PyExc_TypeError, "required field \"attr\" missing from Attribute");
9417 return 1;
9418 }
9419 else {
9420 int res;
9421 if (_Py_EnterRecursiveCall(" while traversing 'Attribute' node")) {
9422 goto failed;
9423 }
9424 res = obj2ast_identifier(state, tmp, &attr, arena);
9425 _Py_LeaveRecursiveCall();
9426 if (res != 0) goto failed;
9427 Py_CLEAR(tmp);
9428 }
9429 if (_PyObject_LookupAttr(obj, state->ctx, &tmp) < 0) {
9430 return 1;
9431 }
9432 if (tmp == NULL) {
9433 PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Attribute");
9434 return 1;
9435 }
9436 else {
9437 int res;
9438 if (_Py_EnterRecursiveCall(" while traversing 'Attribute' node")) {
9439 goto failed;
9440 }
9441 res = obj2ast_expr_context(state, tmp, &ctx, arena);
9442 _Py_LeaveRecursiveCall();
9443 if (res != 0) goto failed;
9444 Py_CLEAR(tmp);
9445 }
9446 *out = _PyAST_Attribute(value, attr, ctx, lineno, col_offset,
9447 end_lineno, end_col_offset, arena);
9448 if (*out == NULL) goto failed;
9449 return 0;
9450 }
9451 tp = state->Subscript_type;
9452 isinstance = PyObject_IsInstance(obj, tp);
9453 if (isinstance == -1) {
9454 return 1;
9455 }
9456 if (isinstance) {
9457 expr_ty value;
9458 expr_ty slice;
9459 expr_context_ty ctx;
9460
9461 if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
9462 return 1;
9463 }
9464 if (tmp == NULL) {
9465 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Subscript");
9466 return 1;
9467 }
9468 else {
9469 int res;
9470 if (_Py_EnterRecursiveCall(" while traversing 'Subscript' node")) {
9471 goto failed;
9472 }
9473 res = obj2ast_expr(state, tmp, &value, arena);
9474 _Py_LeaveRecursiveCall();
9475 if (res != 0) goto failed;
9476 Py_CLEAR(tmp);
9477 }
9478 if (_PyObject_LookupAttr(obj, state->slice, &tmp) < 0) {
9479 return 1;
9480 }
9481 if (tmp == NULL) {
9482 PyErr_SetString(PyExc_TypeError, "required field \"slice\" missing from Subscript");
9483 return 1;
9484 }
9485 else {
9486 int res;
9487 if (_Py_EnterRecursiveCall(" while traversing 'Subscript' node")) {
9488 goto failed;
9489 }
9490 res = obj2ast_expr(state, tmp, &slice, arena);
9491 _Py_LeaveRecursiveCall();
9492 if (res != 0) goto failed;
9493 Py_CLEAR(tmp);
9494 }
9495 if (_PyObject_LookupAttr(obj, state->ctx, &tmp) < 0) {
9496 return 1;
9497 }
9498 if (tmp == NULL) {
9499 PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Subscript");
9500 return 1;
9501 }
9502 else {
9503 int res;
9504 if (_Py_EnterRecursiveCall(" while traversing 'Subscript' node")) {
9505 goto failed;
9506 }
9507 res = obj2ast_expr_context(state, tmp, &ctx, arena);
9508 _Py_LeaveRecursiveCall();
9509 if (res != 0) goto failed;
9510 Py_CLEAR(tmp);
9511 }
9512 *out = _PyAST_Subscript(value, slice, ctx, lineno, col_offset,
9513 end_lineno, end_col_offset, arena);
9514 if (*out == NULL) goto failed;
9515 return 0;
9516 }
9517 tp = state->Starred_type;
9518 isinstance = PyObject_IsInstance(obj, tp);
9519 if (isinstance == -1) {
9520 return 1;
9521 }
9522 if (isinstance) {
9523 expr_ty value;
9524 expr_context_ty ctx;
9525
9526 if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
9527 return 1;
9528 }
9529 if (tmp == NULL) {
9530 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Starred");
9531 return 1;
9532 }
9533 else {
9534 int res;
9535 if (_Py_EnterRecursiveCall(" while traversing 'Starred' node")) {
9536 goto failed;
9537 }
9538 res = obj2ast_expr(state, tmp, &value, arena);
9539 _Py_LeaveRecursiveCall();
9540 if (res != 0) goto failed;
9541 Py_CLEAR(tmp);
9542 }
9543 if (_PyObject_LookupAttr(obj, state->ctx, &tmp) < 0) {
9544 return 1;
9545 }
9546 if (tmp == NULL) {
9547 PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Starred");
9548 return 1;
9549 }
9550 else {
9551 int res;
9552 if (_Py_EnterRecursiveCall(" while traversing 'Starred' node")) {
9553 goto failed;
9554 }
9555 res = obj2ast_expr_context(state, tmp, &ctx, arena);
9556 _Py_LeaveRecursiveCall();
9557 if (res != 0) goto failed;
9558 Py_CLEAR(tmp);
9559 }
9560 *out = _PyAST_Starred(value, ctx, lineno, col_offset, end_lineno,
9561 end_col_offset, arena);
9562 if (*out == NULL) goto failed;
9563 return 0;
9564 }
9565 tp = state->Name_type;
9566 isinstance = PyObject_IsInstance(obj, tp);
9567 if (isinstance == -1) {
9568 return 1;
9569 }
9570 if (isinstance) {
9571 identifier id;
9572 expr_context_ty ctx;
9573
9574 if (_PyObject_LookupAttr(obj, state->id, &tmp) < 0) {
9575 return 1;
9576 }
9577 if (tmp == NULL) {
9578 PyErr_SetString(PyExc_TypeError, "required field \"id\" missing from Name");
9579 return 1;
9580 }
9581 else {
9582 int res;
9583 if (_Py_EnterRecursiveCall(" while traversing 'Name' node")) {
9584 goto failed;
9585 }
9586 res = obj2ast_identifier(state, tmp, &id, arena);
9587 _Py_LeaveRecursiveCall();
9588 if (res != 0) goto failed;
9589 Py_CLEAR(tmp);
9590 }
9591 if (_PyObject_LookupAttr(obj, state->ctx, &tmp) < 0) {
9592 return 1;
9593 }
9594 if (tmp == NULL) {
9595 PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Name");
9596 return 1;
9597 }
9598 else {
9599 int res;
9600 if (_Py_EnterRecursiveCall(" while traversing 'Name' node")) {
9601 goto failed;
9602 }
9603 res = obj2ast_expr_context(state, tmp, &ctx, arena);
9604 _Py_LeaveRecursiveCall();
9605 if (res != 0) goto failed;
9606 Py_CLEAR(tmp);
9607 }
9608 *out = _PyAST_Name(id, ctx, lineno, col_offset, end_lineno,
9609 end_col_offset, arena);
9610 if (*out == NULL) goto failed;
9611 return 0;
9612 }
9613 tp = state->List_type;
9614 isinstance = PyObject_IsInstance(obj, tp);
9615 if (isinstance == -1) {
9616 return 1;
9617 }
9618 if (isinstance) {
9619 asdl_expr_seq* elts;
9620 expr_context_ty ctx;
9621
9622 if (_PyObject_LookupAttr(obj, state->elts, &tmp) < 0) {
9623 return 1;
9624 }
9625 if (tmp == NULL) {
9626 PyErr_SetString(PyExc_TypeError, "required field \"elts\" missing from List");
9627 return 1;
9628 }
9629 else {
9630 int res;
9631 Py_ssize_t len;
9632 Py_ssize_t i;
9633 if (!PyList_Check(tmp)) {
9634 PyErr_Format(PyExc_TypeError, "List field \"elts\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
9635 goto failed;
9636 }
9637 len = PyList_GET_SIZE(tmp);
9638 elts = _Py_asdl_expr_seq_new(len, arena);
9639 if (elts == NULL) goto failed;
9640 for (i = 0; i < len; i++) {
9641 expr_ty val;
9642 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
9643 Py_INCREF(tmp2);
9644 if (_Py_EnterRecursiveCall(" while traversing 'List' node")) {
9645 goto failed;
9646 }
9647 res = obj2ast_expr(state, tmp2, &val, arena);
9648 _Py_LeaveRecursiveCall();
9649 Py_DECREF(tmp2);
9650 if (res != 0) goto failed;
9651 if (len != PyList_GET_SIZE(tmp)) {
9652 PyErr_SetString(PyExc_RuntimeError, "List field \"elts\" changed size during iteration");
9653 goto failed;
9654 }
9655 asdl_seq_SET(elts, i, val);
9656 }
9657 Py_CLEAR(tmp);
9658 }
9659 if (_PyObject_LookupAttr(obj, state->ctx, &tmp) < 0) {
9660 return 1;
9661 }
9662 if (tmp == NULL) {
9663 PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from List");
9664 return 1;
9665 }
9666 else {
9667 int res;
9668 if (_Py_EnterRecursiveCall(" while traversing 'List' node")) {
9669 goto failed;
9670 }
9671 res = obj2ast_expr_context(state, tmp, &ctx, arena);
9672 _Py_LeaveRecursiveCall();
9673 if (res != 0) goto failed;
9674 Py_CLEAR(tmp);
9675 }
9676 *out = _PyAST_List(elts, ctx, lineno, col_offset, end_lineno,
9677 end_col_offset, arena);
9678 if (*out == NULL) goto failed;
9679 return 0;
9680 }
9681 tp = state->Tuple_type;
9682 isinstance = PyObject_IsInstance(obj, tp);
9683 if (isinstance == -1) {
9684 return 1;
9685 }
9686 if (isinstance) {
9687 asdl_expr_seq* elts;
9688 expr_context_ty ctx;
9689
9690 if (_PyObject_LookupAttr(obj, state->elts, &tmp) < 0) {
9691 return 1;
9692 }
9693 if (tmp == NULL) {
9694 PyErr_SetString(PyExc_TypeError, "required field \"elts\" missing from Tuple");
9695 return 1;
9696 }
9697 else {
9698 int res;
9699 Py_ssize_t len;
9700 Py_ssize_t i;
9701 if (!PyList_Check(tmp)) {
9702 PyErr_Format(PyExc_TypeError, "Tuple field \"elts\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
9703 goto failed;
9704 }
9705 len = PyList_GET_SIZE(tmp);
9706 elts = _Py_asdl_expr_seq_new(len, arena);
9707 if (elts == NULL) goto failed;
9708 for (i = 0; i < len; i++) {
9709 expr_ty val;
9710 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
9711 Py_INCREF(tmp2);
9712 if (_Py_EnterRecursiveCall(" while traversing 'Tuple' node")) {
9713 goto failed;
9714 }
9715 res = obj2ast_expr(state, tmp2, &val, arena);
9716 _Py_LeaveRecursiveCall();
9717 Py_DECREF(tmp2);
9718 if (res != 0) goto failed;
9719 if (len != PyList_GET_SIZE(tmp)) {
9720 PyErr_SetString(PyExc_RuntimeError, "Tuple field \"elts\" changed size during iteration");
9721 goto failed;
9722 }
9723 asdl_seq_SET(elts, i, val);
9724 }
9725 Py_CLEAR(tmp);
9726 }
9727 if (_PyObject_LookupAttr(obj, state->ctx, &tmp) < 0) {
9728 return 1;
9729 }
9730 if (tmp == NULL) {
9731 PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Tuple");
9732 return 1;
9733 }
9734 else {
9735 int res;
9736 if (_Py_EnterRecursiveCall(" while traversing 'Tuple' node")) {
9737 goto failed;
9738 }
9739 res = obj2ast_expr_context(state, tmp, &ctx, arena);
9740 _Py_LeaveRecursiveCall();
9741 if (res != 0) goto failed;
9742 Py_CLEAR(tmp);
9743 }
9744 *out = _PyAST_Tuple(elts, ctx, lineno, col_offset, end_lineno,
9745 end_col_offset, arena);
9746 if (*out == NULL) goto failed;
9747 return 0;
9748 }
9749 tp = state->Slice_type;
9750 isinstance = PyObject_IsInstance(obj, tp);
9751 if (isinstance == -1) {
9752 return 1;
9753 }
9754 if (isinstance) {
9755 expr_ty lower;
9756 expr_ty upper;
9757 expr_ty step;
9758
9759 if (_PyObject_LookupAttr(obj, state->lower, &tmp) < 0) {
9760 return 1;
9761 }
9762 if (tmp == NULL || tmp == Py_None) {
9763 Py_CLEAR(tmp);
9764 lower = NULL;
9765 }
9766 else {
9767 int res;
9768 if (_Py_EnterRecursiveCall(" while traversing 'Slice' node")) {
9769 goto failed;
9770 }
9771 res = obj2ast_expr(state, tmp, &lower, arena);
9772 _Py_LeaveRecursiveCall();
9773 if (res != 0) goto failed;
9774 Py_CLEAR(tmp);
9775 }
9776 if (_PyObject_LookupAttr(obj, state->upper, &tmp) < 0) {
9777 return 1;
9778 }
9779 if (tmp == NULL || tmp == Py_None) {
9780 Py_CLEAR(tmp);
9781 upper = NULL;
9782 }
9783 else {
9784 int res;
9785 if (_Py_EnterRecursiveCall(" while traversing 'Slice' node")) {
9786 goto failed;
9787 }
9788 res = obj2ast_expr(state, tmp, &upper, arena);
9789 _Py_LeaveRecursiveCall();
9790 if (res != 0) goto failed;
9791 Py_CLEAR(tmp);
9792 }
9793 if (_PyObject_LookupAttr(obj, state->step, &tmp) < 0) {
9794 return 1;
9795 }
9796 if (tmp == NULL || tmp == Py_None) {
9797 Py_CLEAR(tmp);
9798 step = NULL;
9799 }
9800 else {
9801 int res;
9802 if (_Py_EnterRecursiveCall(" while traversing 'Slice' node")) {
9803 goto failed;
9804 }
9805 res = obj2ast_expr(state, tmp, &step, arena);
9806 _Py_LeaveRecursiveCall();
9807 if (res != 0) goto failed;
9808 Py_CLEAR(tmp);
9809 }
9810 *out = _PyAST_Slice(lower, upper, step, lineno, col_offset, end_lineno,
9811 end_col_offset, arena);
9812 if (*out == NULL) goto failed;
9813 return 0;
9814 }
9815
9816 PyErr_Format(PyExc_TypeError, "expected some sort of expr, but got %R", obj);
9817 failed:
9818 Py_XDECREF(tmp);
9819 return 1;
9820 }
9821
9822 int
9823 obj2ast_expr_context(struct ast_state *state, PyObject* obj, expr_context_ty*
9824 out, PyArena* arena)
9825 {
9826 int isinstance;
9827
9828 isinstance = PyObject_IsInstance(obj, state->Load_type);
9829 if (isinstance == -1) {
9830 return 1;
9831 }
9832 if (isinstance) {
9833 *out = Load;
9834 return 0;
9835 }
9836 isinstance = PyObject_IsInstance(obj, state->Store_type);
9837 if (isinstance == -1) {
9838 return 1;
9839 }
9840 if (isinstance) {
9841 *out = Store;
9842 return 0;
9843 }
9844 isinstance = PyObject_IsInstance(obj, state->Del_type);
9845 if (isinstance == -1) {
9846 return 1;
9847 }
9848 if (isinstance) {
9849 *out = Del;
9850 return 0;
9851 }
9852
9853 PyErr_Format(PyExc_TypeError, "expected some sort of expr_context, but got %R", obj);
9854 return 1;
9855 }
9856
9857 int
9858 obj2ast_boolop(struct ast_state *state, PyObject* obj, boolop_ty* out, PyArena*
9859 arena)
9860 {
9861 int isinstance;
9862
9863 isinstance = PyObject_IsInstance(obj, state->And_type);
9864 if (isinstance == -1) {
9865 return 1;
9866 }
9867 if (isinstance) {
9868 *out = And;
9869 return 0;
9870 }
9871 isinstance = PyObject_IsInstance(obj, state->Or_type);
9872 if (isinstance == -1) {
9873 return 1;
9874 }
9875 if (isinstance) {
9876 *out = Or;
9877 return 0;
9878 }
9879
9880 PyErr_Format(PyExc_TypeError, "expected some sort of boolop, but got %R", obj);
9881 return 1;
9882 }
9883
9884 int
9885 obj2ast_operator(struct ast_state *state, PyObject* obj, operator_ty* out,
9886 PyArena* arena)
9887 {
9888 int isinstance;
9889
9890 isinstance = PyObject_IsInstance(obj, state->Add_type);
9891 if (isinstance == -1) {
9892 return 1;
9893 }
9894 if (isinstance) {
9895 *out = Add;
9896 return 0;
9897 }
9898 isinstance = PyObject_IsInstance(obj, state->Sub_type);
9899 if (isinstance == -1) {
9900 return 1;
9901 }
9902 if (isinstance) {
9903 *out = Sub;
9904 return 0;
9905 }
9906 isinstance = PyObject_IsInstance(obj, state->Mult_type);
9907 if (isinstance == -1) {
9908 return 1;
9909 }
9910 if (isinstance) {
9911 *out = Mult;
9912 return 0;
9913 }
9914 isinstance = PyObject_IsInstance(obj, state->MatMult_type);
9915 if (isinstance == -1) {
9916 return 1;
9917 }
9918 if (isinstance) {
9919 *out = MatMult;
9920 return 0;
9921 }
9922 isinstance = PyObject_IsInstance(obj, state->Div_type);
9923 if (isinstance == -1) {
9924 return 1;
9925 }
9926 if (isinstance) {
9927 *out = Div;
9928 return 0;
9929 }
9930 isinstance = PyObject_IsInstance(obj, state->Mod_type);
9931 if (isinstance == -1) {
9932 return 1;
9933 }
9934 if (isinstance) {
9935 *out = Mod;
9936 return 0;
9937 }
9938 isinstance = PyObject_IsInstance(obj, state->Pow_type);
9939 if (isinstance == -1) {
9940 return 1;
9941 }
9942 if (isinstance) {
9943 *out = Pow;
9944 return 0;
9945 }
9946 isinstance = PyObject_IsInstance(obj, state->LShift_type);
9947 if (isinstance == -1) {
9948 return 1;
9949 }
9950 if (isinstance) {
9951 *out = LShift;
9952 return 0;
9953 }
9954 isinstance = PyObject_IsInstance(obj, state->RShift_type);
9955 if (isinstance == -1) {
9956 return 1;
9957 }
9958 if (isinstance) {
9959 *out = RShift;
9960 return 0;
9961 }
9962 isinstance = PyObject_IsInstance(obj, state->BitOr_type);
9963 if (isinstance == -1) {
9964 return 1;
9965 }
9966 if (isinstance) {
9967 *out = BitOr;
9968 return 0;
9969 }
9970 isinstance = PyObject_IsInstance(obj, state->BitXor_type);
9971 if (isinstance == -1) {
9972 return 1;
9973 }
9974 if (isinstance) {
9975 *out = BitXor;
9976 return 0;
9977 }
9978 isinstance = PyObject_IsInstance(obj, state->BitAnd_type);
9979 if (isinstance == -1) {
9980 return 1;
9981 }
9982 if (isinstance) {
9983 *out = BitAnd;
9984 return 0;
9985 }
9986 isinstance = PyObject_IsInstance(obj, state->FloorDiv_type);
9987 if (isinstance == -1) {
9988 return 1;
9989 }
9990 if (isinstance) {
9991 *out = FloorDiv;
9992 return 0;
9993 }
9994
9995 PyErr_Format(PyExc_TypeError, "expected some sort of operator, but got %R", obj);
9996 return 1;
9997 }
9998
9999 int
10000 obj2ast_unaryop(struct ast_state *state, PyObject* obj, unaryop_ty* out,
10001 PyArena* arena)
10002 {
10003 int isinstance;
10004
10005 isinstance = PyObject_IsInstance(obj, state->Invert_type);
10006 if (isinstance == -1) {
10007 return 1;
10008 }
10009 if (isinstance) {
10010 *out = Invert;
10011 return 0;
10012 }
10013 isinstance = PyObject_IsInstance(obj, state->Not_type);
10014 if (isinstance == -1) {
10015 return 1;
10016 }
10017 if (isinstance) {
10018 *out = Not;
10019 return 0;
10020 }
10021 isinstance = PyObject_IsInstance(obj, state->UAdd_type);
10022 if (isinstance == -1) {
10023 return 1;
10024 }
10025 if (isinstance) {
10026 *out = UAdd;
10027 return 0;
10028 }
10029 isinstance = PyObject_IsInstance(obj, state->USub_type);
10030 if (isinstance == -1) {
10031 return 1;
10032 }
10033 if (isinstance) {
10034 *out = USub;
10035 return 0;
10036 }
10037
10038 PyErr_Format(PyExc_TypeError, "expected some sort of unaryop, but got %R", obj);
10039 return 1;
10040 }
10041
10042 int
10043 obj2ast_cmpop(struct ast_state *state, PyObject* obj, cmpop_ty* out, PyArena*
10044 arena)
10045 {
10046 int isinstance;
10047
10048 isinstance = PyObject_IsInstance(obj, state->Eq_type);
10049 if (isinstance == -1) {
10050 return 1;
10051 }
10052 if (isinstance) {
10053 *out = Eq;
10054 return 0;
10055 }
10056 isinstance = PyObject_IsInstance(obj, state->NotEq_type);
10057 if (isinstance == -1) {
10058 return 1;
10059 }
10060 if (isinstance) {
10061 *out = NotEq;
10062 return 0;
10063 }
10064 isinstance = PyObject_IsInstance(obj, state->Lt_type);
10065 if (isinstance == -1) {
10066 return 1;
10067 }
10068 if (isinstance) {
10069 *out = Lt;
10070 return 0;
10071 }
10072 isinstance = PyObject_IsInstance(obj, state->LtE_type);
10073 if (isinstance == -1) {
10074 return 1;
10075 }
10076 if (isinstance) {
10077 *out = LtE;
10078 return 0;
10079 }
10080 isinstance = PyObject_IsInstance(obj, state->Gt_type);
10081 if (isinstance == -1) {
10082 return 1;
10083 }
10084 if (isinstance) {
10085 *out = Gt;
10086 return 0;
10087 }
10088 isinstance = PyObject_IsInstance(obj, state->GtE_type);
10089 if (isinstance == -1) {
10090 return 1;
10091 }
10092 if (isinstance) {
10093 *out = GtE;
10094 return 0;
10095 }
10096 isinstance = PyObject_IsInstance(obj, state->Is_type);
10097 if (isinstance == -1) {
10098 return 1;
10099 }
10100 if (isinstance) {
10101 *out = Is;
10102 return 0;
10103 }
10104 isinstance = PyObject_IsInstance(obj, state->IsNot_type);
10105 if (isinstance == -1) {
10106 return 1;
10107 }
10108 if (isinstance) {
10109 *out = IsNot;
10110 return 0;
10111 }
10112 isinstance = PyObject_IsInstance(obj, state->In_type);
10113 if (isinstance == -1) {
10114 return 1;
10115 }
10116 if (isinstance) {
10117 *out = In;
10118 return 0;
10119 }
10120 isinstance = PyObject_IsInstance(obj, state->NotIn_type);
10121 if (isinstance == -1) {
10122 return 1;
10123 }
10124 if (isinstance) {
10125 *out = NotIn;
10126 return 0;
10127 }
10128
10129 PyErr_Format(PyExc_TypeError, "expected some sort of cmpop, but got %R", obj);
10130 return 1;
10131 }
10132
10133 int
10134 obj2ast_comprehension(struct ast_state *state, PyObject* obj, comprehension_ty*
10135 out, PyArena* arena)
10136 {
10137 PyObject* tmp = NULL;
10138 expr_ty target;
10139 expr_ty iter;
10140 asdl_expr_seq* ifs;
10141 int is_async;
10142
10143 if (_PyObject_LookupAttr(obj, state->target, &tmp) < 0) {
10144 return 1;
10145 }
10146 if (tmp == NULL) {
10147 PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from comprehension");
10148 return 1;
10149 }
10150 else {
10151 int res;
10152 if (_Py_EnterRecursiveCall(" while traversing 'comprehension' node")) {
10153 goto failed;
10154 }
10155 res = obj2ast_expr(state, tmp, &target, arena);
10156 _Py_LeaveRecursiveCall();
10157 if (res != 0) goto failed;
10158 Py_CLEAR(tmp);
10159 }
10160 if (_PyObject_LookupAttr(obj, state->iter, &tmp) < 0) {
10161 return 1;
10162 }
10163 if (tmp == NULL) {
10164 PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from comprehension");
10165 return 1;
10166 }
10167 else {
10168 int res;
10169 if (_Py_EnterRecursiveCall(" while traversing 'comprehension' node")) {
10170 goto failed;
10171 }
10172 res = obj2ast_expr(state, tmp, &iter, arena);
10173 _Py_LeaveRecursiveCall();
10174 if (res != 0) goto failed;
10175 Py_CLEAR(tmp);
10176 }
10177 if (_PyObject_LookupAttr(obj, state->ifs, &tmp) < 0) {
10178 return 1;
10179 }
10180 if (tmp == NULL) {
10181 PyErr_SetString(PyExc_TypeError, "required field \"ifs\" missing from comprehension");
10182 return 1;
10183 }
10184 else {
10185 int res;
10186 Py_ssize_t len;
10187 Py_ssize_t i;
10188 if (!PyList_Check(tmp)) {
10189 PyErr_Format(PyExc_TypeError, "comprehension field \"ifs\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
10190 goto failed;
10191 }
10192 len = PyList_GET_SIZE(tmp);
10193 ifs = _Py_asdl_expr_seq_new(len, arena);
10194 if (ifs == NULL) goto failed;
10195 for (i = 0; i < len; i++) {
10196 expr_ty val;
10197 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
10198 Py_INCREF(tmp2);
10199 if (_Py_EnterRecursiveCall(" while traversing 'comprehension' node")) {
10200 goto failed;
10201 }
10202 res = obj2ast_expr(state, tmp2, &val, arena);
10203 _Py_LeaveRecursiveCall();
10204 Py_DECREF(tmp2);
10205 if (res != 0) goto failed;
10206 if (len != PyList_GET_SIZE(tmp)) {
10207 PyErr_SetString(PyExc_RuntimeError, "comprehension field \"ifs\" changed size during iteration");
10208 goto failed;
10209 }
10210 asdl_seq_SET(ifs, i, val);
10211 }
10212 Py_CLEAR(tmp);
10213 }
10214 if (_PyObject_LookupAttr(obj, state->is_async, &tmp) < 0) {
10215 return 1;
10216 }
10217 if (tmp == NULL) {
10218 PyErr_SetString(PyExc_TypeError, "required field \"is_async\" missing from comprehension");
10219 return 1;
10220 }
10221 else {
10222 int res;
10223 if (_Py_EnterRecursiveCall(" while traversing 'comprehension' node")) {
10224 goto failed;
10225 }
10226 res = obj2ast_int(state, tmp, &is_async, arena);
10227 _Py_LeaveRecursiveCall();
10228 if (res != 0) goto failed;
10229 Py_CLEAR(tmp);
10230 }
10231 *out = _PyAST_comprehension(target, iter, ifs, is_async, arena);
10232 return 0;
10233 failed:
10234 Py_XDECREF(tmp);
10235 return 1;
10236 }
10237
10238 int
10239 obj2ast_excepthandler(struct ast_state *state, PyObject* obj, excepthandler_ty*
10240 out, PyArena* arena)
10241 {
10242 int isinstance;
10243
10244 PyObject *tmp = NULL;
10245 PyObject *tp;
10246 int lineno;
10247 int col_offset;
10248 int end_lineno;
10249 int end_col_offset;
10250
10251 if (obj == Py_None) {
10252 *out = NULL;
10253 return 0;
10254 }
10255 if (_PyObject_LookupAttr(obj, state->lineno, &tmp) < 0) {
10256 return 1;
10257 }
10258 if (tmp == NULL) {
10259 PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from excepthandler");
10260 return 1;
10261 }
10262 else {
10263 int res;
10264 if (_Py_EnterRecursiveCall(" while traversing 'excepthandler' node")) {
10265 goto failed;
10266 }
10267 res = obj2ast_int(state, tmp, &lineno, arena);
10268 _Py_LeaveRecursiveCall();
10269 if (res != 0) goto failed;
10270 Py_CLEAR(tmp);
10271 }
10272 if (_PyObject_LookupAttr(obj, state->col_offset, &tmp) < 0) {
10273 return 1;
10274 }
10275 if (tmp == NULL) {
10276 PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from excepthandler");
10277 return 1;
10278 }
10279 else {
10280 int res;
10281 if (_Py_EnterRecursiveCall(" while traversing 'excepthandler' node")) {
10282 goto failed;
10283 }
10284 res = obj2ast_int(state, tmp, &col_offset, arena);
10285 _Py_LeaveRecursiveCall();
10286 if (res != 0) goto failed;
10287 Py_CLEAR(tmp);
10288 }
10289 if (_PyObject_LookupAttr(obj, state->end_lineno, &tmp) < 0) {
10290 return 1;
10291 }
10292 if (tmp == NULL || tmp == Py_None) {
10293 Py_CLEAR(tmp);
10294 end_lineno = lineno;
10295 }
10296 else {
10297 int res;
10298 if (_Py_EnterRecursiveCall(" while traversing 'excepthandler' node")) {
10299 goto failed;
10300 }
10301 res = obj2ast_int(state, tmp, &end_lineno, arena);
10302 _Py_LeaveRecursiveCall();
10303 if (res != 0) goto failed;
10304 Py_CLEAR(tmp);
10305 }
10306 if (_PyObject_LookupAttr(obj, state->end_col_offset, &tmp) < 0) {
10307 return 1;
10308 }
10309 if (tmp == NULL || tmp == Py_None) {
10310 Py_CLEAR(tmp);
10311 end_col_offset = col_offset;
10312 }
10313 else {
10314 int res;
10315 if (_Py_EnterRecursiveCall(" while traversing 'excepthandler' node")) {
10316 goto failed;
10317 }
10318 res = obj2ast_int(state, tmp, &end_col_offset, arena);
10319 _Py_LeaveRecursiveCall();
10320 if (res != 0) goto failed;
10321 Py_CLEAR(tmp);
10322 }
10323 tp = state->ExceptHandler_type;
10324 isinstance = PyObject_IsInstance(obj, tp);
10325 if (isinstance == -1) {
10326 return 1;
10327 }
10328 if (isinstance) {
10329 expr_ty type;
10330 identifier name;
10331 asdl_stmt_seq* body;
10332
10333 if (_PyObject_LookupAttr(obj, state->type, &tmp) < 0) {
10334 return 1;
10335 }
10336 if (tmp == NULL || tmp == Py_None) {
10337 Py_CLEAR(tmp);
10338 type = NULL;
10339 }
10340 else {
10341 int res;
10342 if (_Py_EnterRecursiveCall(" while traversing 'ExceptHandler' node")) {
10343 goto failed;
10344 }
10345 res = obj2ast_expr(state, tmp, &type, arena);
10346 _Py_LeaveRecursiveCall();
10347 if (res != 0) goto failed;
10348 Py_CLEAR(tmp);
10349 }
10350 if (_PyObject_LookupAttr(obj, state->name, &tmp) < 0) {
10351 return 1;
10352 }
10353 if (tmp == NULL || tmp == Py_None) {
10354 Py_CLEAR(tmp);
10355 name = NULL;
10356 }
10357 else {
10358 int res;
10359 if (_Py_EnterRecursiveCall(" while traversing 'ExceptHandler' node")) {
10360 goto failed;
10361 }
10362 res = obj2ast_identifier(state, tmp, &name, arena);
10363 _Py_LeaveRecursiveCall();
10364 if (res != 0) goto failed;
10365 Py_CLEAR(tmp);
10366 }
10367 if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
10368 return 1;
10369 }
10370 if (tmp == NULL) {
10371 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from ExceptHandler");
10372 return 1;
10373 }
10374 else {
10375 int res;
10376 Py_ssize_t len;
10377 Py_ssize_t i;
10378 if (!PyList_Check(tmp)) {
10379 PyErr_Format(PyExc_TypeError, "ExceptHandler field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
10380 goto failed;
10381 }
10382 len = PyList_GET_SIZE(tmp);
10383 body = _Py_asdl_stmt_seq_new(len, arena);
10384 if (body == NULL) goto failed;
10385 for (i = 0; i < len; i++) {
10386 stmt_ty val;
10387 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
10388 Py_INCREF(tmp2);
10389 if (_Py_EnterRecursiveCall(" while traversing 'ExceptHandler' node")) {
10390 goto failed;
10391 }
10392 res = obj2ast_stmt(state, tmp2, &val, arena);
10393 _Py_LeaveRecursiveCall();
10394 Py_DECREF(tmp2);
10395 if (res != 0) goto failed;
10396 if (len != PyList_GET_SIZE(tmp)) {
10397 PyErr_SetString(PyExc_RuntimeError, "ExceptHandler field \"body\" changed size during iteration");
10398 goto failed;
10399 }
10400 asdl_seq_SET(body, i, val);
10401 }
10402 Py_CLEAR(tmp);
10403 }
10404 *out = _PyAST_ExceptHandler(type, name, body, lineno, col_offset,
10405 end_lineno, end_col_offset, arena);
10406 if (*out == NULL) goto failed;
10407 return 0;
10408 }
10409
10410 PyErr_Format(PyExc_TypeError, "expected some sort of excepthandler, but got %R", obj);
10411 failed:
10412 Py_XDECREF(tmp);
10413 return 1;
10414 }
10415
10416 int
10417 obj2ast_arguments(struct ast_state *state, PyObject* obj, arguments_ty* out,
10418 PyArena* arena)
10419 {
10420 PyObject* tmp = NULL;
10421 asdl_arg_seq* posonlyargs;
10422 asdl_arg_seq* args;
10423 arg_ty vararg;
10424 asdl_arg_seq* kwonlyargs;
10425 asdl_expr_seq* kw_defaults;
10426 arg_ty kwarg;
10427 asdl_expr_seq* defaults;
10428
10429 if (_PyObject_LookupAttr(obj, state->posonlyargs, &tmp) < 0) {
10430 return 1;
10431 }
10432 if (tmp == NULL) {
10433 PyErr_SetString(PyExc_TypeError, "required field \"posonlyargs\" missing from arguments");
10434 return 1;
10435 }
10436 else {
10437 int res;
10438 Py_ssize_t len;
10439 Py_ssize_t i;
10440 if (!PyList_Check(tmp)) {
10441 PyErr_Format(PyExc_TypeError, "arguments field \"posonlyargs\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
10442 goto failed;
10443 }
10444 len = PyList_GET_SIZE(tmp);
10445 posonlyargs = _Py_asdl_arg_seq_new(len, arena);
10446 if (posonlyargs == NULL) goto failed;
10447 for (i = 0; i < len; i++) {
10448 arg_ty val;
10449 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
10450 Py_INCREF(tmp2);
10451 if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
10452 goto failed;
10453 }
10454 res = obj2ast_arg(state, tmp2, &val, arena);
10455 _Py_LeaveRecursiveCall();
10456 Py_DECREF(tmp2);
10457 if (res != 0) goto failed;
10458 if (len != PyList_GET_SIZE(tmp)) {
10459 PyErr_SetString(PyExc_RuntimeError, "arguments field \"posonlyargs\" changed size during iteration");
10460 goto failed;
10461 }
10462 asdl_seq_SET(posonlyargs, i, val);
10463 }
10464 Py_CLEAR(tmp);
10465 }
10466 if (_PyObject_LookupAttr(obj, state->args, &tmp) < 0) {
10467 return 1;
10468 }
10469 if (tmp == NULL) {
10470 PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from arguments");
10471 return 1;
10472 }
10473 else {
10474 int res;
10475 Py_ssize_t len;
10476 Py_ssize_t i;
10477 if (!PyList_Check(tmp)) {
10478 PyErr_Format(PyExc_TypeError, "arguments field \"args\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
10479 goto failed;
10480 }
10481 len = PyList_GET_SIZE(tmp);
10482 args = _Py_asdl_arg_seq_new(len, arena);
10483 if (args == NULL) goto failed;
10484 for (i = 0; i < len; i++) {
10485 arg_ty val;
10486 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
10487 Py_INCREF(tmp2);
10488 if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
10489 goto failed;
10490 }
10491 res = obj2ast_arg(state, tmp2, &val, arena);
10492 _Py_LeaveRecursiveCall();
10493 Py_DECREF(tmp2);
10494 if (res != 0) goto failed;
10495 if (len != PyList_GET_SIZE(tmp)) {
10496 PyErr_SetString(PyExc_RuntimeError, "arguments field \"args\" changed size during iteration");
10497 goto failed;
10498 }
10499 asdl_seq_SET(args, i, val);
10500 }
10501 Py_CLEAR(tmp);
10502 }
10503 if (_PyObject_LookupAttr(obj, state->vararg, &tmp) < 0) {
10504 return 1;
10505 }
10506 if (tmp == NULL || tmp == Py_None) {
10507 Py_CLEAR(tmp);
10508 vararg = NULL;
10509 }
10510 else {
10511 int res;
10512 if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
10513 goto failed;
10514 }
10515 res = obj2ast_arg(state, tmp, &vararg, arena);
10516 _Py_LeaveRecursiveCall();
10517 if (res != 0) goto failed;
10518 Py_CLEAR(tmp);
10519 }
10520 if (_PyObject_LookupAttr(obj, state->kwonlyargs, &tmp) < 0) {
10521 return 1;
10522 }
10523 if (tmp == NULL) {
10524 PyErr_SetString(PyExc_TypeError, "required field \"kwonlyargs\" missing from arguments");
10525 return 1;
10526 }
10527 else {
10528 int res;
10529 Py_ssize_t len;
10530 Py_ssize_t i;
10531 if (!PyList_Check(tmp)) {
10532 PyErr_Format(PyExc_TypeError, "arguments field \"kwonlyargs\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
10533 goto failed;
10534 }
10535 len = PyList_GET_SIZE(tmp);
10536 kwonlyargs = _Py_asdl_arg_seq_new(len, arena);
10537 if (kwonlyargs == NULL) goto failed;
10538 for (i = 0; i < len; i++) {
10539 arg_ty val;
10540 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
10541 Py_INCREF(tmp2);
10542 if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
10543 goto failed;
10544 }
10545 res = obj2ast_arg(state, tmp2, &val, arena);
10546 _Py_LeaveRecursiveCall();
10547 Py_DECREF(tmp2);
10548 if (res != 0) goto failed;
10549 if (len != PyList_GET_SIZE(tmp)) {
10550 PyErr_SetString(PyExc_RuntimeError, "arguments field \"kwonlyargs\" changed size during iteration");
10551 goto failed;
10552 }
10553 asdl_seq_SET(kwonlyargs, i, val);
10554 }
10555 Py_CLEAR(tmp);
10556 }
10557 if (_PyObject_LookupAttr(obj, state->kw_defaults, &tmp) < 0) {
10558 return 1;
10559 }
10560 if (tmp == NULL) {
10561 PyErr_SetString(PyExc_TypeError, "required field \"kw_defaults\" missing from arguments");
10562 return 1;
10563 }
10564 else {
10565 int res;
10566 Py_ssize_t len;
10567 Py_ssize_t i;
10568 if (!PyList_Check(tmp)) {
10569 PyErr_Format(PyExc_TypeError, "arguments field \"kw_defaults\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
10570 goto failed;
10571 }
10572 len = PyList_GET_SIZE(tmp);
10573 kw_defaults = _Py_asdl_expr_seq_new(len, arena);
10574 if (kw_defaults == NULL) goto failed;
10575 for (i = 0; i < len; i++) {
10576 expr_ty val;
10577 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
10578 Py_INCREF(tmp2);
10579 if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
10580 goto failed;
10581 }
10582 res = obj2ast_expr(state, tmp2, &val, arena);
10583 _Py_LeaveRecursiveCall();
10584 Py_DECREF(tmp2);
10585 if (res != 0) goto failed;
10586 if (len != PyList_GET_SIZE(tmp)) {
10587 PyErr_SetString(PyExc_RuntimeError, "arguments field \"kw_defaults\" changed size during iteration");
10588 goto failed;
10589 }
10590 asdl_seq_SET(kw_defaults, i, val);
10591 }
10592 Py_CLEAR(tmp);
10593 }
10594 if (_PyObject_LookupAttr(obj, state->kwarg, &tmp) < 0) {
10595 return 1;
10596 }
10597 if (tmp == NULL || tmp == Py_None) {
10598 Py_CLEAR(tmp);
10599 kwarg = NULL;
10600 }
10601 else {
10602 int res;
10603 if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
10604 goto failed;
10605 }
10606 res = obj2ast_arg(state, tmp, &kwarg, arena);
10607 _Py_LeaveRecursiveCall();
10608 if (res != 0) goto failed;
10609 Py_CLEAR(tmp);
10610 }
10611 if (_PyObject_LookupAttr(obj, state->defaults, &tmp) < 0) {
10612 return 1;
10613 }
10614 if (tmp == NULL) {
10615 PyErr_SetString(PyExc_TypeError, "required field \"defaults\" missing from arguments");
10616 return 1;
10617 }
10618 else {
10619 int res;
10620 Py_ssize_t len;
10621 Py_ssize_t i;
10622 if (!PyList_Check(tmp)) {
10623 PyErr_Format(PyExc_TypeError, "arguments field \"defaults\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
10624 goto failed;
10625 }
10626 len = PyList_GET_SIZE(tmp);
10627 defaults = _Py_asdl_expr_seq_new(len, arena);
10628 if (defaults == NULL) goto failed;
10629 for (i = 0; i < len; i++) {
10630 expr_ty val;
10631 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
10632 Py_INCREF(tmp2);
10633 if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
10634 goto failed;
10635 }
10636 res = obj2ast_expr(state, tmp2, &val, arena);
10637 _Py_LeaveRecursiveCall();
10638 Py_DECREF(tmp2);
10639 if (res != 0) goto failed;
10640 if (len != PyList_GET_SIZE(tmp)) {
10641 PyErr_SetString(PyExc_RuntimeError, "arguments field \"defaults\" changed size during iteration");
10642 goto failed;
10643 }
10644 asdl_seq_SET(defaults, i, val);
10645 }
10646 Py_CLEAR(tmp);
10647 }
10648 *out = _PyAST_arguments(posonlyargs, args, vararg, kwonlyargs, kw_defaults,
10649 kwarg, defaults, arena);
10650 return 0;
10651 failed:
10652 Py_XDECREF(tmp);
10653 return 1;
10654 }
10655
10656 int
10657 obj2ast_arg(struct ast_state *state, PyObject* obj, arg_ty* out, PyArena* arena)
10658 {
10659 PyObject* tmp = NULL;
10660 identifier arg;
10661 expr_ty annotation;
10662 string type_comment;
10663 int lineno;
10664 int col_offset;
10665 int end_lineno;
10666 int end_col_offset;
10667
10668 if (_PyObject_LookupAttr(obj, state->arg, &tmp) < 0) {
10669 return 1;
10670 }
10671 if (tmp == NULL) {
10672 PyErr_SetString(PyExc_TypeError, "required field \"arg\" missing from arg");
10673 return 1;
10674 }
10675 else {
10676 int res;
10677 if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
10678 goto failed;
10679 }
10680 res = obj2ast_identifier(state, tmp, &arg, arena);
10681 _Py_LeaveRecursiveCall();
10682 if (res != 0) goto failed;
10683 Py_CLEAR(tmp);
10684 }
10685 if (_PyObject_LookupAttr(obj, state->annotation, &tmp) < 0) {
10686 return 1;
10687 }
10688 if (tmp == NULL || tmp == Py_None) {
10689 Py_CLEAR(tmp);
10690 annotation = NULL;
10691 }
10692 else {
10693 int res;
10694 if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
10695 goto failed;
10696 }
10697 res = obj2ast_expr(state, tmp, &annotation, arena);
10698 _Py_LeaveRecursiveCall();
10699 if (res != 0) goto failed;
10700 Py_CLEAR(tmp);
10701 }
10702 if (_PyObject_LookupAttr(obj, state->type_comment, &tmp) < 0) {
10703 return 1;
10704 }
10705 if (tmp == NULL || tmp == Py_None) {
10706 Py_CLEAR(tmp);
10707 type_comment = NULL;
10708 }
10709 else {
10710 int res;
10711 if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
10712 goto failed;
10713 }
10714 res = obj2ast_string(state, tmp, &type_comment, arena);
10715 _Py_LeaveRecursiveCall();
10716 if (res != 0) goto failed;
10717 Py_CLEAR(tmp);
10718 }
10719 if (_PyObject_LookupAttr(obj, state->lineno, &tmp) < 0) {
10720 return 1;
10721 }
10722 if (tmp == NULL) {
10723 PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from arg");
10724 return 1;
10725 }
10726 else {
10727 int res;
10728 if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
10729 goto failed;
10730 }
10731 res = obj2ast_int(state, tmp, &lineno, arena);
10732 _Py_LeaveRecursiveCall();
10733 if (res != 0) goto failed;
10734 Py_CLEAR(tmp);
10735 }
10736 if (_PyObject_LookupAttr(obj, state->col_offset, &tmp) < 0) {
10737 return 1;
10738 }
10739 if (tmp == NULL) {
10740 PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from arg");
10741 return 1;
10742 }
10743 else {
10744 int res;
10745 if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
10746 goto failed;
10747 }
10748 res = obj2ast_int(state, tmp, &col_offset, arena);
10749 _Py_LeaveRecursiveCall();
10750 if (res != 0) goto failed;
10751 Py_CLEAR(tmp);
10752 }
10753 if (_PyObject_LookupAttr(obj, state->end_lineno, &tmp) < 0) {
10754 return 1;
10755 }
10756 if (tmp == NULL || tmp == Py_None) {
10757 Py_CLEAR(tmp);
10758 end_lineno = lineno;
10759 }
10760 else {
10761 int res;
10762 if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
10763 goto failed;
10764 }
10765 res = obj2ast_int(state, tmp, &end_lineno, arena);
10766 _Py_LeaveRecursiveCall();
10767 if (res != 0) goto failed;
10768 Py_CLEAR(tmp);
10769 }
10770 if (_PyObject_LookupAttr(obj, state->end_col_offset, &tmp) < 0) {
10771 return 1;
10772 }
10773 if (tmp == NULL || tmp == Py_None) {
10774 Py_CLEAR(tmp);
10775 end_col_offset = col_offset;
10776 }
10777 else {
10778 int res;
10779 if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
10780 goto failed;
10781 }
10782 res = obj2ast_int(state, tmp, &end_col_offset, arena);
10783 _Py_LeaveRecursiveCall();
10784 if (res != 0) goto failed;
10785 Py_CLEAR(tmp);
10786 }
10787 *out = _PyAST_arg(arg, annotation, type_comment, lineno, col_offset,
10788 end_lineno, end_col_offset, arena);
10789 return 0;
10790 failed:
10791 Py_XDECREF(tmp);
10792 return 1;
10793 }
10794
10795 int
10796 obj2ast_keyword(struct ast_state *state, PyObject* obj, keyword_ty* out,
10797 PyArena* arena)
10798 {
10799 PyObject* tmp = NULL;
10800 identifier arg;
10801 expr_ty value;
10802 int lineno;
10803 int col_offset;
10804 int end_lineno;
10805 int end_col_offset;
10806
10807 if (_PyObject_LookupAttr(obj, state->arg, &tmp) < 0) {
10808 return 1;
10809 }
10810 if (tmp == NULL || tmp == Py_None) {
10811 Py_CLEAR(tmp);
10812 arg = NULL;
10813 }
10814 else {
10815 int res;
10816 if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
10817 goto failed;
10818 }
10819 res = obj2ast_identifier(state, tmp, &arg, arena);
10820 _Py_LeaveRecursiveCall();
10821 if (res != 0) goto failed;
10822 Py_CLEAR(tmp);
10823 }
10824 if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
10825 return 1;
10826 }
10827 if (tmp == NULL) {
10828 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from keyword");
10829 return 1;
10830 }
10831 else {
10832 int res;
10833 if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
10834 goto failed;
10835 }
10836 res = obj2ast_expr(state, tmp, &value, arena);
10837 _Py_LeaveRecursiveCall();
10838 if (res != 0) goto failed;
10839 Py_CLEAR(tmp);
10840 }
10841 if (_PyObject_LookupAttr(obj, state->lineno, &tmp) < 0) {
10842 return 1;
10843 }
10844 if (tmp == NULL) {
10845 PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from keyword");
10846 return 1;
10847 }
10848 else {
10849 int res;
10850 if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
10851 goto failed;
10852 }
10853 res = obj2ast_int(state, tmp, &lineno, arena);
10854 _Py_LeaveRecursiveCall();
10855 if (res != 0) goto failed;
10856 Py_CLEAR(tmp);
10857 }
10858 if (_PyObject_LookupAttr(obj, state->col_offset, &tmp) < 0) {
10859 return 1;
10860 }
10861 if (tmp == NULL) {
10862 PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from keyword");
10863 return 1;
10864 }
10865 else {
10866 int res;
10867 if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
10868 goto failed;
10869 }
10870 res = obj2ast_int(state, tmp, &col_offset, arena);
10871 _Py_LeaveRecursiveCall();
10872 if (res != 0) goto failed;
10873 Py_CLEAR(tmp);
10874 }
10875 if (_PyObject_LookupAttr(obj, state->end_lineno, &tmp) < 0) {
10876 return 1;
10877 }
10878 if (tmp == NULL || tmp == Py_None) {
10879 Py_CLEAR(tmp);
10880 end_lineno = lineno;
10881 }
10882 else {
10883 int res;
10884 if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
10885 goto failed;
10886 }
10887 res = obj2ast_int(state, tmp, &end_lineno, arena);
10888 _Py_LeaveRecursiveCall();
10889 if (res != 0) goto failed;
10890 Py_CLEAR(tmp);
10891 }
10892 if (_PyObject_LookupAttr(obj, state->end_col_offset, &tmp) < 0) {
10893 return 1;
10894 }
10895 if (tmp == NULL || tmp == Py_None) {
10896 Py_CLEAR(tmp);
10897 end_col_offset = col_offset;
10898 }
10899 else {
10900 int res;
10901 if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
10902 goto failed;
10903 }
10904 res = obj2ast_int(state, tmp, &end_col_offset, arena);
10905 _Py_LeaveRecursiveCall();
10906 if (res != 0) goto failed;
10907 Py_CLEAR(tmp);
10908 }
10909 *out = _PyAST_keyword(arg, value, lineno, col_offset, end_lineno,
10910 end_col_offset, arena);
10911 return 0;
10912 failed:
10913 Py_XDECREF(tmp);
10914 return 1;
10915 }
10916
10917 int
10918 obj2ast_alias(struct ast_state *state, PyObject* obj, alias_ty* out, PyArena*
10919 arena)
10920 {
10921 PyObject* tmp = NULL;
10922 identifier name;
10923 identifier asname;
10924 int lineno;
10925 int col_offset;
10926 int end_lineno;
10927 int end_col_offset;
10928
10929 if (_PyObject_LookupAttr(obj, state->name, &tmp) < 0) {
10930 return 1;
10931 }
10932 if (tmp == NULL) {
10933 PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from alias");
10934 return 1;
10935 }
10936 else {
10937 int res;
10938 if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
10939 goto failed;
10940 }
10941 res = obj2ast_identifier(state, tmp, &name, arena);
10942 _Py_LeaveRecursiveCall();
10943 if (res != 0) goto failed;
10944 Py_CLEAR(tmp);
10945 }
10946 if (_PyObject_LookupAttr(obj, state->asname, &tmp) < 0) {
10947 return 1;
10948 }
10949 if (tmp == NULL || tmp == Py_None) {
10950 Py_CLEAR(tmp);
10951 asname = NULL;
10952 }
10953 else {
10954 int res;
10955 if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
10956 goto failed;
10957 }
10958 res = obj2ast_identifier(state, tmp, &asname, arena);
10959 _Py_LeaveRecursiveCall();
10960 if (res != 0) goto failed;
10961 Py_CLEAR(tmp);
10962 }
10963 if (_PyObject_LookupAttr(obj, state->lineno, &tmp) < 0) {
10964 return 1;
10965 }
10966 if (tmp == NULL) {
10967 PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from alias");
10968 return 1;
10969 }
10970 else {
10971 int res;
10972 if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
10973 goto failed;
10974 }
10975 res = obj2ast_int(state, tmp, &lineno, arena);
10976 _Py_LeaveRecursiveCall();
10977 if (res != 0) goto failed;
10978 Py_CLEAR(tmp);
10979 }
10980 if (_PyObject_LookupAttr(obj, state->col_offset, &tmp) < 0) {
10981 return 1;
10982 }
10983 if (tmp == NULL) {
10984 PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from alias");
10985 return 1;
10986 }
10987 else {
10988 int res;
10989 if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
10990 goto failed;
10991 }
10992 res = obj2ast_int(state, tmp, &col_offset, arena);
10993 _Py_LeaveRecursiveCall();
10994 if (res != 0) goto failed;
10995 Py_CLEAR(tmp);
10996 }
10997 if (_PyObject_LookupAttr(obj, state->end_lineno, &tmp) < 0) {
10998 return 1;
10999 }
11000 if (tmp == NULL || tmp == Py_None) {
11001 Py_CLEAR(tmp);
11002 end_lineno = lineno;
11003 }
11004 else {
11005 int res;
11006 if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
11007 goto failed;
11008 }
11009 res = obj2ast_int(state, tmp, &end_lineno, arena);
11010 _Py_LeaveRecursiveCall();
11011 if (res != 0) goto failed;
11012 Py_CLEAR(tmp);
11013 }
11014 if (_PyObject_LookupAttr(obj, state->end_col_offset, &tmp) < 0) {
11015 return 1;
11016 }
11017 if (tmp == NULL || tmp == Py_None) {
11018 Py_CLEAR(tmp);
11019 end_col_offset = col_offset;
11020 }
11021 else {
11022 int res;
11023 if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
11024 goto failed;
11025 }
11026 res = obj2ast_int(state, tmp, &end_col_offset, arena);
11027 _Py_LeaveRecursiveCall();
11028 if (res != 0) goto failed;
11029 Py_CLEAR(tmp);
11030 }
11031 *out = _PyAST_alias(name, asname, lineno, col_offset, end_lineno,
11032 end_col_offset, arena);
11033 return 0;
11034 failed:
11035 Py_XDECREF(tmp);
11036 return 1;
11037 }
11038
11039 int
11040 obj2ast_withitem(struct ast_state *state, PyObject* obj, withitem_ty* out,
11041 PyArena* arena)
11042 {
11043 PyObject* tmp = NULL;
11044 expr_ty context_expr;
11045 expr_ty optional_vars;
11046
11047 if (_PyObject_LookupAttr(obj, state->context_expr, &tmp) < 0) {
11048 return 1;
11049 }
11050 if (tmp == NULL) {
11051 PyErr_SetString(PyExc_TypeError, "required field \"context_expr\" missing from withitem");
11052 return 1;
11053 }
11054 else {
11055 int res;
11056 if (_Py_EnterRecursiveCall(" while traversing 'withitem' node")) {
11057 goto failed;
11058 }
11059 res = obj2ast_expr(state, tmp, &context_expr, arena);
11060 _Py_LeaveRecursiveCall();
11061 if (res != 0) goto failed;
11062 Py_CLEAR(tmp);
11063 }
11064 if (_PyObject_LookupAttr(obj, state->optional_vars, &tmp) < 0) {
11065 return 1;
11066 }
11067 if (tmp == NULL || tmp == Py_None) {
11068 Py_CLEAR(tmp);
11069 optional_vars = NULL;
11070 }
11071 else {
11072 int res;
11073 if (_Py_EnterRecursiveCall(" while traversing 'withitem' node")) {
11074 goto failed;
11075 }
11076 res = obj2ast_expr(state, tmp, &optional_vars, arena);
11077 _Py_LeaveRecursiveCall();
11078 if (res != 0) goto failed;
11079 Py_CLEAR(tmp);
11080 }
11081 *out = _PyAST_withitem(context_expr, optional_vars, arena);
11082 return 0;
11083 failed:
11084 Py_XDECREF(tmp);
11085 return 1;
11086 }
11087
11088 int
11089 obj2ast_match_case(struct ast_state *state, PyObject* obj, match_case_ty* out,
11090 PyArena* arena)
11091 {
11092 PyObject* tmp = NULL;
11093 pattern_ty pattern;
11094 expr_ty guard;
11095 asdl_stmt_seq* body;
11096
11097 if (_PyObject_LookupAttr(obj, state->pattern, &tmp) < 0) {
11098 return 1;
11099 }
11100 if (tmp == NULL) {
11101 PyErr_SetString(PyExc_TypeError, "required field \"pattern\" missing from match_case");
11102 return 1;
11103 }
11104 else {
11105 int res;
11106 if (_Py_EnterRecursiveCall(" while traversing 'match_case' node")) {
11107 goto failed;
11108 }
11109 res = obj2ast_pattern(state, tmp, &pattern, arena);
11110 _Py_LeaveRecursiveCall();
11111 if (res != 0) goto failed;
11112 Py_CLEAR(tmp);
11113 }
11114 if (_PyObject_LookupAttr(obj, state->guard, &tmp) < 0) {
11115 return 1;
11116 }
11117 if (tmp == NULL || tmp == Py_None) {
11118 Py_CLEAR(tmp);
11119 guard = NULL;
11120 }
11121 else {
11122 int res;
11123 if (_Py_EnterRecursiveCall(" while traversing 'match_case' node")) {
11124 goto failed;
11125 }
11126 res = obj2ast_expr(state, tmp, &guard, arena);
11127 _Py_LeaveRecursiveCall();
11128 if (res != 0) goto failed;
11129 Py_CLEAR(tmp);
11130 }
11131 if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
11132 return 1;
11133 }
11134 if (tmp == NULL) {
11135 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from match_case");
11136 return 1;
11137 }
11138 else {
11139 int res;
11140 Py_ssize_t len;
11141 Py_ssize_t i;
11142 if (!PyList_Check(tmp)) {
11143 PyErr_Format(PyExc_TypeError, "match_case field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11144 goto failed;
11145 }
11146 len = PyList_GET_SIZE(tmp);
11147 body = _Py_asdl_stmt_seq_new(len, arena);
11148 if (body == NULL) goto failed;
11149 for (i = 0; i < len; i++) {
11150 stmt_ty val;
11151 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
11152 Py_INCREF(tmp2);
11153 if (_Py_EnterRecursiveCall(" while traversing 'match_case' node")) {
11154 goto failed;
11155 }
11156 res = obj2ast_stmt(state, tmp2, &val, arena);
11157 _Py_LeaveRecursiveCall();
11158 Py_DECREF(tmp2);
11159 if (res != 0) goto failed;
11160 if (len != PyList_GET_SIZE(tmp)) {
11161 PyErr_SetString(PyExc_RuntimeError, "match_case field \"body\" changed size during iteration");
11162 goto failed;
11163 }
11164 asdl_seq_SET(body, i, val);
11165 }
11166 Py_CLEAR(tmp);
11167 }
11168 *out = _PyAST_match_case(pattern, guard, body, arena);
11169 return 0;
11170 failed:
11171 Py_XDECREF(tmp);
11172 return 1;
11173 }
11174
11175 int
11176 obj2ast_pattern(struct ast_state *state, PyObject* obj, pattern_ty* out,
11177 PyArena* arena)
11178 {
11179 int isinstance;
11180
11181 PyObject *tmp = NULL;
11182 PyObject *tp;
11183 int lineno;
11184 int col_offset;
11185 int end_lineno;
11186 int end_col_offset;
11187
11188 if (obj == Py_None) {
11189 *out = NULL;
11190 return 0;
11191 }
11192 if (_PyObject_LookupAttr(obj, state->lineno, &tmp) < 0) {
11193 return 1;
11194 }
11195 if (tmp == NULL) {
11196 PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from pattern");
11197 return 1;
11198 }
11199 else {
11200 int res;
11201 if (_Py_EnterRecursiveCall(" while traversing 'pattern' node")) {
11202 goto failed;
11203 }
11204 res = obj2ast_int(state, tmp, &lineno, arena);
11205 _Py_LeaveRecursiveCall();
11206 if (res != 0) goto failed;
11207 Py_CLEAR(tmp);
11208 }
11209 if (_PyObject_LookupAttr(obj, state->col_offset, &tmp) < 0) {
11210 return 1;
11211 }
11212 if (tmp == NULL) {
11213 PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from pattern");
11214 return 1;
11215 }
11216 else {
11217 int res;
11218 if (_Py_EnterRecursiveCall(" while traversing 'pattern' node")) {
11219 goto failed;
11220 }
11221 res = obj2ast_int(state, tmp, &col_offset, arena);
11222 _Py_LeaveRecursiveCall();
11223 if (res != 0) goto failed;
11224 Py_CLEAR(tmp);
11225 }
11226 if (_PyObject_LookupAttr(obj, state->end_lineno, &tmp) < 0) {
11227 return 1;
11228 }
11229 if (tmp == NULL) {
11230 PyErr_SetString(PyExc_TypeError, "required field \"end_lineno\" missing from pattern");
11231 return 1;
11232 }
11233 else {
11234 int res;
11235 if (_Py_EnterRecursiveCall(" while traversing 'pattern' node")) {
11236 goto failed;
11237 }
11238 res = obj2ast_int(state, tmp, &end_lineno, arena);
11239 _Py_LeaveRecursiveCall();
11240 if (res != 0) goto failed;
11241 Py_CLEAR(tmp);
11242 }
11243 if (_PyObject_LookupAttr(obj, state->end_col_offset, &tmp) < 0) {
11244 return 1;
11245 }
11246 if (tmp == NULL) {
11247 PyErr_SetString(PyExc_TypeError, "required field \"end_col_offset\" missing from pattern");
11248 return 1;
11249 }
11250 else {
11251 int res;
11252 if (_Py_EnterRecursiveCall(" while traversing 'pattern' node")) {
11253 goto failed;
11254 }
11255 res = obj2ast_int(state, tmp, &end_col_offset, arena);
11256 _Py_LeaveRecursiveCall();
11257 if (res != 0) goto failed;
11258 Py_CLEAR(tmp);
11259 }
11260 tp = state->MatchValue_type;
11261 isinstance = PyObject_IsInstance(obj, tp);
11262 if (isinstance == -1) {
11263 return 1;
11264 }
11265 if (isinstance) {
11266 expr_ty value;
11267
11268 if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
11269 return 1;
11270 }
11271 if (tmp == NULL) {
11272 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from MatchValue");
11273 return 1;
11274 }
11275 else {
11276 int res;
11277 if (_Py_EnterRecursiveCall(" while traversing 'MatchValue' node")) {
11278 goto failed;
11279 }
11280 res = obj2ast_expr(state, tmp, &value, arena);
11281 _Py_LeaveRecursiveCall();
11282 if (res != 0) goto failed;
11283 Py_CLEAR(tmp);
11284 }
11285 *out = _PyAST_MatchValue(value, lineno, col_offset, end_lineno,
11286 end_col_offset, arena);
11287 if (*out == NULL) goto failed;
11288 return 0;
11289 }
11290 tp = state->MatchSingleton_type;
11291 isinstance = PyObject_IsInstance(obj, tp);
11292 if (isinstance == -1) {
11293 return 1;
11294 }
11295 if (isinstance) {
11296 constant value;
11297
11298 if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
11299 return 1;
11300 }
11301 if (tmp == NULL) {
11302 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from MatchSingleton");
11303 return 1;
11304 }
11305 else {
11306 int res;
11307 if (_Py_EnterRecursiveCall(" while traversing 'MatchSingleton' node")) {
11308 goto failed;
11309 }
11310 res = obj2ast_constant(state, tmp, &value, arena);
11311 _Py_LeaveRecursiveCall();
11312 if (res != 0) goto failed;
11313 Py_CLEAR(tmp);
11314 }
11315 *out = _PyAST_MatchSingleton(value, lineno, col_offset, end_lineno,
11316 end_col_offset, arena);
11317 if (*out == NULL) goto failed;
11318 return 0;
11319 }
11320 tp = state->MatchSequence_type;
11321 isinstance = PyObject_IsInstance(obj, tp);
11322 if (isinstance == -1) {
11323 return 1;
11324 }
11325 if (isinstance) {
11326 asdl_pattern_seq* patterns;
11327
11328 if (_PyObject_LookupAttr(obj, state->patterns, &tmp) < 0) {
11329 return 1;
11330 }
11331 if (tmp == NULL) {
11332 PyErr_SetString(PyExc_TypeError, "required field \"patterns\" missing from MatchSequence");
11333 return 1;
11334 }
11335 else {
11336 int res;
11337 Py_ssize_t len;
11338 Py_ssize_t i;
11339 if (!PyList_Check(tmp)) {
11340 PyErr_Format(PyExc_TypeError, "MatchSequence field \"patterns\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11341 goto failed;
11342 }
11343 len = PyList_GET_SIZE(tmp);
11344 patterns = _Py_asdl_pattern_seq_new(len, arena);
11345 if (patterns == NULL) goto failed;
11346 for (i = 0; i < len; i++) {
11347 pattern_ty val;
11348 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
11349 Py_INCREF(tmp2);
11350 if (_Py_EnterRecursiveCall(" while traversing 'MatchSequence' node")) {
11351 goto failed;
11352 }
11353 res = obj2ast_pattern(state, tmp2, &val, arena);
11354 _Py_LeaveRecursiveCall();
11355 Py_DECREF(tmp2);
11356 if (res != 0) goto failed;
11357 if (len != PyList_GET_SIZE(tmp)) {
11358 PyErr_SetString(PyExc_RuntimeError, "MatchSequence field \"patterns\" changed size during iteration");
11359 goto failed;
11360 }
11361 asdl_seq_SET(patterns, i, val);
11362 }
11363 Py_CLEAR(tmp);
11364 }
11365 *out = _PyAST_MatchSequence(patterns, lineno, col_offset, end_lineno,
11366 end_col_offset, arena);
11367 if (*out == NULL) goto failed;
11368 return 0;
11369 }
11370 tp = state->MatchMapping_type;
11371 isinstance = PyObject_IsInstance(obj, tp);
11372 if (isinstance == -1) {
11373 return 1;
11374 }
11375 if (isinstance) {
11376 asdl_expr_seq* keys;
11377 asdl_pattern_seq* patterns;
11378 identifier rest;
11379
11380 if (_PyObject_LookupAttr(obj, state->keys, &tmp) < 0) {
11381 return 1;
11382 }
11383 if (tmp == NULL) {
11384 PyErr_SetString(PyExc_TypeError, "required field \"keys\" missing from MatchMapping");
11385 return 1;
11386 }
11387 else {
11388 int res;
11389 Py_ssize_t len;
11390 Py_ssize_t i;
11391 if (!PyList_Check(tmp)) {
11392 PyErr_Format(PyExc_TypeError, "MatchMapping field \"keys\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11393 goto failed;
11394 }
11395 len = PyList_GET_SIZE(tmp);
11396 keys = _Py_asdl_expr_seq_new(len, arena);
11397 if (keys == NULL) goto failed;
11398 for (i = 0; i < len; i++) {
11399 expr_ty val;
11400 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
11401 Py_INCREF(tmp2);
11402 if (_Py_EnterRecursiveCall(" while traversing 'MatchMapping' node")) {
11403 goto failed;
11404 }
11405 res = obj2ast_expr(state, tmp2, &val, arena);
11406 _Py_LeaveRecursiveCall();
11407 Py_DECREF(tmp2);
11408 if (res != 0) goto failed;
11409 if (len != PyList_GET_SIZE(tmp)) {
11410 PyErr_SetString(PyExc_RuntimeError, "MatchMapping field \"keys\" changed size during iteration");
11411 goto failed;
11412 }
11413 asdl_seq_SET(keys, i, val);
11414 }
11415 Py_CLEAR(tmp);
11416 }
11417 if (_PyObject_LookupAttr(obj, state->patterns, &tmp) < 0) {
11418 return 1;
11419 }
11420 if (tmp == NULL) {
11421 PyErr_SetString(PyExc_TypeError, "required field \"patterns\" missing from MatchMapping");
11422 return 1;
11423 }
11424 else {
11425 int res;
11426 Py_ssize_t len;
11427 Py_ssize_t i;
11428 if (!PyList_Check(tmp)) {
11429 PyErr_Format(PyExc_TypeError, "MatchMapping field \"patterns\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11430 goto failed;
11431 }
11432 len = PyList_GET_SIZE(tmp);
11433 patterns = _Py_asdl_pattern_seq_new(len, arena);
11434 if (patterns == NULL) goto failed;
11435 for (i = 0; i < len; i++) {
11436 pattern_ty val;
11437 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
11438 Py_INCREF(tmp2);
11439 if (_Py_EnterRecursiveCall(" while traversing 'MatchMapping' node")) {
11440 goto failed;
11441 }
11442 res = obj2ast_pattern(state, tmp2, &val, arena);
11443 _Py_LeaveRecursiveCall();
11444 Py_DECREF(tmp2);
11445 if (res != 0) goto failed;
11446 if (len != PyList_GET_SIZE(tmp)) {
11447 PyErr_SetString(PyExc_RuntimeError, "MatchMapping field \"patterns\" changed size during iteration");
11448 goto failed;
11449 }
11450 asdl_seq_SET(patterns, i, val);
11451 }
11452 Py_CLEAR(tmp);
11453 }
11454 if (_PyObject_LookupAttr(obj, state->rest, &tmp) < 0) {
11455 return 1;
11456 }
11457 if (tmp == NULL || tmp == Py_None) {
11458 Py_CLEAR(tmp);
11459 rest = NULL;
11460 }
11461 else {
11462 int res;
11463 if (_Py_EnterRecursiveCall(" while traversing 'MatchMapping' node")) {
11464 goto failed;
11465 }
11466 res = obj2ast_identifier(state, tmp, &rest, arena);
11467 _Py_LeaveRecursiveCall();
11468 if (res != 0) goto failed;
11469 Py_CLEAR(tmp);
11470 }
11471 *out = _PyAST_MatchMapping(keys, patterns, rest, lineno, col_offset,
11472 end_lineno, end_col_offset, arena);
11473 if (*out == NULL) goto failed;
11474 return 0;
11475 }
11476 tp = state->MatchClass_type;
11477 isinstance = PyObject_IsInstance(obj, tp);
11478 if (isinstance == -1) {
11479 return 1;
11480 }
11481 if (isinstance) {
11482 expr_ty cls;
11483 asdl_pattern_seq* patterns;
11484 asdl_identifier_seq* kwd_attrs;
11485 asdl_pattern_seq* kwd_patterns;
11486
11487 if (_PyObject_LookupAttr(obj, state->cls, &tmp) < 0) {
11488 return 1;
11489 }
11490 if (tmp == NULL) {
11491 PyErr_SetString(PyExc_TypeError, "required field \"cls\" missing from MatchClass");
11492 return 1;
11493 }
11494 else {
11495 int res;
11496 if (_Py_EnterRecursiveCall(" while traversing 'MatchClass' node")) {
11497 goto failed;
11498 }
11499 res = obj2ast_expr(state, tmp, &cls, arena);
11500 _Py_LeaveRecursiveCall();
11501 if (res != 0) goto failed;
11502 Py_CLEAR(tmp);
11503 }
11504 if (_PyObject_LookupAttr(obj, state->patterns, &tmp) < 0) {
11505 return 1;
11506 }
11507 if (tmp == NULL) {
11508 PyErr_SetString(PyExc_TypeError, "required field \"patterns\" missing from MatchClass");
11509 return 1;
11510 }
11511 else {
11512 int res;
11513 Py_ssize_t len;
11514 Py_ssize_t i;
11515 if (!PyList_Check(tmp)) {
11516 PyErr_Format(PyExc_TypeError, "MatchClass field \"patterns\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11517 goto failed;
11518 }
11519 len = PyList_GET_SIZE(tmp);
11520 patterns = _Py_asdl_pattern_seq_new(len, arena);
11521 if (patterns == NULL) goto failed;
11522 for (i = 0; i < len; i++) {
11523 pattern_ty val;
11524 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
11525 Py_INCREF(tmp2);
11526 if (_Py_EnterRecursiveCall(" while traversing 'MatchClass' node")) {
11527 goto failed;
11528 }
11529 res = obj2ast_pattern(state, tmp2, &val, arena);
11530 _Py_LeaveRecursiveCall();
11531 Py_DECREF(tmp2);
11532 if (res != 0) goto failed;
11533 if (len != PyList_GET_SIZE(tmp)) {
11534 PyErr_SetString(PyExc_RuntimeError, "MatchClass field \"patterns\" changed size during iteration");
11535 goto failed;
11536 }
11537 asdl_seq_SET(patterns, i, val);
11538 }
11539 Py_CLEAR(tmp);
11540 }
11541 if (_PyObject_LookupAttr(obj, state->kwd_attrs, &tmp) < 0) {
11542 return 1;
11543 }
11544 if (tmp == NULL) {
11545 PyErr_SetString(PyExc_TypeError, "required field \"kwd_attrs\" missing from MatchClass");
11546 return 1;
11547 }
11548 else {
11549 int res;
11550 Py_ssize_t len;
11551 Py_ssize_t i;
11552 if (!PyList_Check(tmp)) {
11553 PyErr_Format(PyExc_TypeError, "MatchClass field \"kwd_attrs\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11554 goto failed;
11555 }
11556 len = PyList_GET_SIZE(tmp);
11557 kwd_attrs = _Py_asdl_identifier_seq_new(len, arena);
11558 if (kwd_attrs == NULL) goto failed;
11559 for (i = 0; i < len; i++) {
11560 identifier val;
11561 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
11562 Py_INCREF(tmp2);
11563 if (_Py_EnterRecursiveCall(" while traversing 'MatchClass' node")) {
11564 goto failed;
11565 }
11566 res = obj2ast_identifier(state, tmp2, &val, arena);
11567 _Py_LeaveRecursiveCall();
11568 Py_DECREF(tmp2);
11569 if (res != 0) goto failed;
11570 if (len != PyList_GET_SIZE(tmp)) {
11571 PyErr_SetString(PyExc_RuntimeError, "MatchClass field \"kwd_attrs\" changed size during iteration");
11572 goto failed;
11573 }
11574 asdl_seq_SET(kwd_attrs, i, val);
11575 }
11576 Py_CLEAR(tmp);
11577 }
11578 if (_PyObject_LookupAttr(obj, state->kwd_patterns, &tmp) < 0) {
11579 return 1;
11580 }
11581 if (tmp == NULL) {
11582 PyErr_SetString(PyExc_TypeError, "required field \"kwd_patterns\" missing from MatchClass");
11583 return 1;
11584 }
11585 else {
11586 int res;
11587 Py_ssize_t len;
11588 Py_ssize_t i;
11589 if (!PyList_Check(tmp)) {
11590 PyErr_Format(PyExc_TypeError, "MatchClass field \"kwd_patterns\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11591 goto failed;
11592 }
11593 len = PyList_GET_SIZE(tmp);
11594 kwd_patterns = _Py_asdl_pattern_seq_new(len, arena);
11595 if (kwd_patterns == NULL) goto failed;
11596 for (i = 0; i < len; i++) {
11597 pattern_ty val;
11598 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
11599 Py_INCREF(tmp2);
11600 if (_Py_EnterRecursiveCall(" while traversing 'MatchClass' node")) {
11601 goto failed;
11602 }
11603 res = obj2ast_pattern(state, tmp2, &val, arena);
11604 _Py_LeaveRecursiveCall();
11605 Py_DECREF(tmp2);
11606 if (res != 0) goto failed;
11607 if (len != PyList_GET_SIZE(tmp)) {
11608 PyErr_SetString(PyExc_RuntimeError, "MatchClass field \"kwd_patterns\" changed size during iteration");
11609 goto failed;
11610 }
11611 asdl_seq_SET(kwd_patterns, i, val);
11612 }
11613 Py_CLEAR(tmp);
11614 }
11615 *out = _PyAST_MatchClass(cls, patterns, kwd_attrs, kwd_patterns,
11616 lineno, col_offset, end_lineno,
11617 end_col_offset, arena);
11618 if (*out == NULL) goto failed;
11619 return 0;
11620 }
11621 tp = state->MatchStar_type;
11622 isinstance = PyObject_IsInstance(obj, tp);
11623 if (isinstance == -1) {
11624 return 1;
11625 }
11626 if (isinstance) {
11627 identifier name;
11628
11629 if (_PyObject_LookupAttr(obj, state->name, &tmp) < 0) {
11630 return 1;
11631 }
11632 if (tmp == NULL || tmp == Py_None) {
11633 Py_CLEAR(tmp);
11634 name = NULL;
11635 }
11636 else {
11637 int res;
11638 if (_Py_EnterRecursiveCall(" while traversing 'MatchStar' node")) {
11639 goto failed;
11640 }
11641 res = obj2ast_identifier(state, tmp, &name, arena);
11642 _Py_LeaveRecursiveCall();
11643 if (res != 0) goto failed;
11644 Py_CLEAR(tmp);
11645 }
11646 *out = _PyAST_MatchStar(name, lineno, col_offset, end_lineno,
11647 end_col_offset, arena);
11648 if (*out == NULL) goto failed;
11649 return 0;
11650 }
11651 tp = state->MatchAs_type;
11652 isinstance = PyObject_IsInstance(obj, tp);
11653 if (isinstance == -1) {
11654 return 1;
11655 }
11656 if (isinstance) {
11657 pattern_ty pattern;
11658 identifier name;
11659
11660 if (_PyObject_LookupAttr(obj, state->pattern, &tmp) < 0) {
11661 return 1;
11662 }
11663 if (tmp == NULL || tmp == Py_None) {
11664 Py_CLEAR(tmp);
11665 pattern = NULL;
11666 }
11667 else {
11668 int res;
11669 if (_Py_EnterRecursiveCall(" while traversing 'MatchAs' node")) {
11670 goto failed;
11671 }
11672 res = obj2ast_pattern(state, tmp, &pattern, arena);
11673 _Py_LeaveRecursiveCall();
11674 if (res != 0) goto failed;
11675 Py_CLEAR(tmp);
11676 }
11677 if (_PyObject_LookupAttr(obj, state->name, &tmp) < 0) {
11678 return 1;
11679 }
11680 if (tmp == NULL || tmp == Py_None) {
11681 Py_CLEAR(tmp);
11682 name = NULL;
11683 }
11684 else {
11685 int res;
11686 if (_Py_EnterRecursiveCall(" while traversing 'MatchAs' node")) {
11687 goto failed;
11688 }
11689 res = obj2ast_identifier(state, tmp, &name, arena);
11690 _Py_LeaveRecursiveCall();
11691 if (res != 0) goto failed;
11692 Py_CLEAR(tmp);
11693 }
11694 *out = _PyAST_MatchAs(pattern, name, lineno, col_offset, end_lineno,
11695 end_col_offset, arena);
11696 if (*out == NULL) goto failed;
11697 return 0;
11698 }
11699 tp = state->MatchOr_type;
11700 isinstance = PyObject_IsInstance(obj, tp);
11701 if (isinstance == -1) {
11702 return 1;
11703 }
11704 if (isinstance) {
11705 asdl_pattern_seq* patterns;
11706
11707 if (_PyObject_LookupAttr(obj, state->patterns, &tmp) < 0) {
11708 return 1;
11709 }
11710 if (tmp == NULL) {
11711 PyErr_SetString(PyExc_TypeError, "required field \"patterns\" missing from MatchOr");
11712 return 1;
11713 }
11714 else {
11715 int res;
11716 Py_ssize_t len;
11717 Py_ssize_t i;
11718 if (!PyList_Check(tmp)) {
11719 PyErr_Format(PyExc_TypeError, "MatchOr field \"patterns\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11720 goto failed;
11721 }
11722 len = PyList_GET_SIZE(tmp);
11723 patterns = _Py_asdl_pattern_seq_new(len, arena);
11724 if (patterns == NULL) goto failed;
11725 for (i = 0; i < len; i++) {
11726 pattern_ty val;
11727 PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
11728 Py_INCREF(tmp2);
11729 if (_Py_EnterRecursiveCall(" while traversing 'MatchOr' node")) {
11730 goto failed;
11731 }
11732 res = obj2ast_pattern(state, tmp2, &val, arena);
11733 _Py_LeaveRecursiveCall();
11734 Py_DECREF(tmp2);
11735 if (res != 0) goto failed;
11736 if (len != PyList_GET_SIZE(tmp)) {
11737 PyErr_SetString(PyExc_RuntimeError, "MatchOr field \"patterns\" changed size during iteration");
11738 goto failed;
11739 }
11740 asdl_seq_SET(patterns, i, val);
11741 }
11742 Py_CLEAR(tmp);
11743 }
11744 *out = _PyAST_MatchOr(patterns, lineno, col_offset, end_lineno,
11745 end_col_offset, arena);
11746 if (*out == NULL) goto failed;
11747 return 0;
11748 }
11749
11750 PyErr_Format(PyExc_TypeError, "expected some sort of pattern, but got %R", obj);
11751 failed:
11752 Py_XDECREF(tmp);
11753 return 1;
11754 }
11755
11756 int
11757 obj2ast_type_ignore(struct ast_state *state, PyObject* obj, type_ignore_ty*
11758 out, PyArena* arena)
11759 {
11760 int isinstance;
11761
11762 PyObject *tmp = NULL;
11763 PyObject *tp;
11764
11765 if (obj == Py_None) {
11766 *out = NULL;
11767 return 0;
11768 }
11769 tp = state->TypeIgnore_type;
11770 isinstance = PyObject_IsInstance(obj, tp);
11771 if (isinstance == -1) {
11772 return 1;
11773 }
11774 if (isinstance) {
11775 int lineno;
11776 string tag;
11777
11778 if (_PyObject_LookupAttr(obj, state->lineno, &tmp) < 0) {
11779 return 1;
11780 }
11781 if (tmp == NULL) {
11782 PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from TypeIgnore");
11783 return 1;
11784 }
11785 else {
11786 int res;
11787 if (_Py_EnterRecursiveCall(" while traversing 'TypeIgnore' node")) {
11788 goto failed;
11789 }
11790 res = obj2ast_int(state, tmp, &lineno, arena);
11791 _Py_LeaveRecursiveCall();
11792 if (res != 0) goto failed;
11793 Py_CLEAR(tmp);
11794 }
11795 if (_PyObject_LookupAttr(obj, state->tag, &tmp) < 0) {
11796 return 1;
11797 }
11798 if (tmp == NULL) {
11799 PyErr_SetString(PyExc_TypeError, "required field \"tag\" missing from TypeIgnore");
11800 return 1;
11801 }
11802 else {
11803 int res;
11804 if (_Py_EnterRecursiveCall(" while traversing 'TypeIgnore' node")) {
11805 goto failed;
11806 }
11807 res = obj2ast_string(state, tmp, &tag, arena);
11808 _Py_LeaveRecursiveCall();
11809 if (res != 0) goto failed;
11810 Py_CLEAR(tmp);
11811 }
11812 *out = _PyAST_TypeIgnore(lineno, tag, arena);
11813 if (*out == NULL) goto failed;
11814 return 0;
11815 }
11816
11817 PyErr_Format(PyExc_TypeError, "expected some sort of type_ignore, but got %R", obj);
11818 failed:
11819 Py_XDECREF(tmp);
11820 return 1;
11821 }
11822
11823
11824 static int
11825 770 astmodule_exec(PyObject *m)
11826 {
11827 770 struct ast_state *state = get_ast_state();
11828
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 770 times.
770 if (state == NULL) {
11829 return -1;
11830 }
11831
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "AST", state->AST_type) < 0) {
11832 return -1;
11833 }
11834
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddIntMacro(m, PyCF_ALLOW_TOP_LEVEL_AWAIT) < 0) {
11835 return -1;
11836 }
11837
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddIntMacro(m, PyCF_ONLY_AST) < 0) {
11838 return -1;
11839 }
11840
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddIntMacro(m, PyCF_TYPE_COMMENTS) < 0) {
11841 return -1;
11842 }
11843
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "mod", state->mod_type) < 0) {
11844 return -1;
11845 }
11846
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "Module", state->Module_type) < 0) {
11847 return -1;
11848 }
11849
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "Interactive", state->Interactive_type) < 0) {
11850 return -1;
11851 }
11852
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "Expression", state->Expression_type) < 0) {
11853 return -1;
11854 }
11855
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "FunctionType", state->FunctionType_type) < 0)
11856 {
11857 return -1;
11858 }
11859
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "stmt", state->stmt_type) < 0) {
11860 return -1;
11861 }
11862
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "FunctionDef", state->FunctionDef_type) < 0) {
11863 return -1;
11864 }
11865
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "AsyncFunctionDef",
11866 state->AsyncFunctionDef_type) < 0) {
11867 return -1;
11868 }
11869
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "ClassDef", state->ClassDef_type) < 0) {
11870 return -1;
11871 }
11872
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "Return", state->Return_type) < 0) {
11873 return -1;
11874 }
11875
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "Delete", state->Delete_type) < 0) {
11876 return -1;
11877 }
11878
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "Assign", state->Assign_type) < 0) {
11879 return -1;
11880 }
11881
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "AugAssign", state->AugAssign_type) < 0) {
11882 return -1;
11883 }
11884
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "AnnAssign", state->AnnAssign_type) < 0) {
11885 return -1;
11886 }
11887
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "For", state->For_type) < 0) {
11888 return -1;
11889 }
11890
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "AsyncFor", state->AsyncFor_type) < 0) {
11891 return -1;
11892 }
11893
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "While", state->While_type) < 0) {
11894 return -1;
11895 }
11896
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "If", state->If_type) < 0) {
11897 return -1;
11898 }
11899
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "With", state->With_type) < 0) {
11900 return -1;
11901 }
11902
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "AsyncWith", state->AsyncWith_type) < 0) {
11903 return -1;
11904 }
11905
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "Match", state->Match_type) < 0) {
11906 return -1;
11907 }
11908
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "Raise", state->Raise_type) < 0) {
11909 return -1;
11910 }
11911
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "Try", state->Try_type) < 0) {
11912 return -1;
11913 }
11914
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "TryStar", state->TryStar_type) < 0) {
11915 return -1;
11916 }
11917
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "Assert", state->Assert_type) < 0) {
11918 return -1;
11919 }
11920
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "Import", state->Import_type) < 0) {
11921 return -1;
11922 }
11923
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "ImportFrom", state->ImportFrom_type) < 0) {
11924 return -1;
11925 }
11926
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "Global", state->Global_type) < 0) {
11927 return -1;
11928 }
11929
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "Nonlocal", state->Nonlocal_type) < 0) {
11930 return -1;
11931 }
11932
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "Expr", state->Expr_type) < 0) {
11933 return -1;
11934 }
11935
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "Pass", state->Pass_type) < 0) {
11936 return -1;
11937 }
11938
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "Break", state->Break_type) < 0) {
11939 return -1;
11940 }
11941
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "Continue", state->Continue_type) < 0) {
11942 return -1;
11943 }
11944
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "expr", state->expr_type) < 0) {
11945 return -1;
11946 }
11947
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "BoolOp", state->BoolOp_type) < 0) {
11948 return -1;
11949 }
11950
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "NamedExpr", state->NamedExpr_type) < 0) {
11951 return -1;
11952 }
11953
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "BinOp", state->BinOp_type) < 0) {
11954 return -1;
11955 }
11956
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "UnaryOp", state->UnaryOp_type) < 0) {
11957 return -1;
11958 }
11959
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "Lambda", state->Lambda_type) < 0) {
11960 return -1;
11961 }
11962
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "IfExp", state->IfExp_type) < 0) {
11963 return -1;
11964 }
11965
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "Dict", state->Dict_type) < 0) {
11966 return -1;
11967 }
11968
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "Set", state->Set_type) < 0) {
11969 return -1;
11970 }
11971
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "ListComp", state->ListComp_type) < 0) {
11972 return -1;
11973 }
11974
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "SetComp", state->SetComp_type) < 0) {
11975 return -1;
11976 }
11977
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "DictComp", state->DictComp_type) < 0) {
11978 return -1;
11979 }
11980
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "GeneratorExp", state->GeneratorExp_type) < 0)
11981 {
11982 return -1;
11983 }
11984
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "Await", state->Await_type) < 0) {
11985 return -1;
11986 }
11987
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "Yield", state->Yield_type) < 0) {
11988 return -1;
11989 }
11990
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "YieldFrom", state->YieldFrom_type) < 0) {
11991 return -1;
11992 }
11993
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "Compare", state->Compare_type) < 0) {
11994 return -1;
11995 }
11996
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "Call", state->Call_type) < 0) {
11997 return -1;
11998 }
11999
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "FormattedValue", state->FormattedValue_type)
12000 < 0) {
12001 return -1;
12002 }
12003
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "JoinedStr", state->JoinedStr_type) < 0) {
12004 return -1;
12005 }
12006
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "Constant", state->Constant_type) < 0) {
12007 return -1;
12008 }
12009
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "Attribute", state->Attribute_type) < 0) {
12010 return -1;
12011 }
12012
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "Subscript", state->Subscript_type) < 0) {
12013 return -1;
12014 }
12015
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "Starred", state->Starred_type) < 0) {
12016 return -1;
12017 }
12018
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "Name", state->Name_type) < 0) {
12019 return -1;
12020 }
12021
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "List", state->List_type) < 0) {
12022 return -1;
12023 }
12024
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "Tuple", state->Tuple_type) < 0) {
12025 return -1;
12026 }
12027
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "Slice", state->Slice_type) < 0) {
12028 return -1;
12029 }
12030
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "expr_context", state->expr_context_type) < 0)
12031 {
12032 return -1;
12033 }
12034
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "Load", state->Load_type) < 0) {
12035 return -1;
12036 }
12037
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "Store", state->Store_type) < 0) {
12038 return -1;
12039 }
12040
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "Del", state->Del_type) < 0) {
12041 return -1;
12042 }
12043
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "boolop", state->boolop_type) < 0) {
12044 return -1;
12045 }
12046
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "And", state->And_type) < 0) {
12047 return -1;
12048 }
12049
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "Or", state->Or_type) < 0) {
12050 return -1;
12051 }
12052
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "operator", state->operator_type) < 0) {
12053 return -1;
12054 }
12055
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "Add", state->Add_type) < 0) {
12056 return -1;
12057 }
12058
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "Sub", state->Sub_type) < 0) {
12059 return -1;
12060 }
12061
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "Mult", state->Mult_type) < 0) {
12062 return -1;
12063 }
12064
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "MatMult", state->MatMult_type) < 0) {
12065 return -1;
12066 }
12067
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "Div", state->Div_type) < 0) {
12068 return -1;
12069 }
12070
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "Mod", state->Mod_type) < 0) {
12071 return -1;
12072 }
12073
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "Pow", state->Pow_type) < 0) {
12074 return -1;
12075 }
12076
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "LShift", state->LShift_type) < 0) {
12077 return -1;
12078 }
12079
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "RShift", state->RShift_type) < 0) {
12080 return -1;
12081 }
12082
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "BitOr", state->BitOr_type) < 0) {
12083 return -1;
12084 }
12085
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "BitXor", state->BitXor_type) < 0) {
12086 return -1;
12087 }
12088
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "BitAnd", state->BitAnd_type) < 0) {
12089 return -1;
12090 }
12091
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "FloorDiv", state->FloorDiv_type) < 0) {
12092 return -1;
12093 }
12094
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "unaryop", state->unaryop_type) < 0) {
12095 return -1;
12096 }
12097
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "Invert", state->Invert_type) < 0) {
12098 return -1;
12099 }
12100
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "Not", state->Not_type) < 0) {
12101 return -1;
12102 }
12103
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "UAdd", state->UAdd_type) < 0) {
12104 return -1;
12105 }
12106
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "USub", state->USub_type) < 0) {
12107 return -1;
12108 }
12109
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "cmpop", state->cmpop_type) < 0) {
12110 return -1;
12111 }
12112
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "Eq", state->Eq_type) < 0) {
12113 return -1;
12114 }
12115
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "NotEq", state->NotEq_type) < 0) {
12116 return -1;
12117 }
12118
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "Lt", state->Lt_type) < 0) {
12119 return -1;
12120 }
12121
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "LtE", state->LtE_type) < 0) {
12122 return -1;
12123 }
12124
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "Gt", state->Gt_type) < 0) {
12125 return -1;
12126 }
12127
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "GtE", state->GtE_type) < 0) {
12128 return -1;
12129 }
12130
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "Is", state->Is_type) < 0) {
12131 return -1;
12132 }
12133
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "IsNot", state->IsNot_type) < 0) {
12134 return -1;
12135 }
12136
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "In", state->In_type) < 0) {
12137 return -1;
12138 }
12139
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "NotIn", state->NotIn_type) < 0) {
12140 return -1;
12141 }
12142
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "comprehension", state->comprehension_type) <
12143 0) {
12144 return -1;
12145 }
12146
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "excepthandler", state->excepthandler_type) <
12147 0) {
12148 return -1;
12149 }
12150
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "ExceptHandler", state->ExceptHandler_type) <
12151 0) {
12152 return -1;
12153 }
12154
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "arguments", state->arguments_type) < 0) {
12155 return -1;
12156 }
12157
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "arg", state->arg_type) < 0) {
12158 return -1;
12159 }
12160
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "keyword", state->keyword_type) < 0) {
12161 return -1;
12162 }
12163
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "alias", state->alias_type) < 0) {
12164 return -1;
12165 }
12166
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "withitem", state->withitem_type) < 0) {
12167 return -1;
12168 }
12169
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "match_case", state->match_case_type) < 0) {
12170 return -1;
12171 }
12172
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "pattern", state->pattern_type) < 0) {
12173 return -1;
12174 }
12175
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "MatchValue", state->MatchValue_type) < 0) {
12176 return -1;
12177 }
12178
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "MatchSingleton", state->MatchSingleton_type)
12179 < 0) {
12180 return -1;
12181 }
12182
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "MatchSequence", state->MatchSequence_type) <
12183 0) {
12184 return -1;
12185 }
12186
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "MatchMapping", state->MatchMapping_type) < 0)
12187 {
12188 return -1;
12189 }
12190
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "MatchClass", state->MatchClass_type) < 0) {
12191 return -1;
12192 }
12193
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "MatchStar", state->MatchStar_type) < 0) {
12194 return -1;
12195 }
12196
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "MatchAs", state->MatchAs_type) < 0) {
12197 return -1;
12198 }
12199
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "MatchOr", state->MatchOr_type) < 0) {
12200 return -1;
12201 }
12202
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "type_ignore", state->type_ignore_type) < 0) {
12203 return -1;
12204 }
12205
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 770 times.
770 if (PyModule_AddObjectRef(m, "TypeIgnore", state->TypeIgnore_type) < 0) {
12206 return -1;
12207 }
12208 770 return 0;
12209 }
12210
12211 static PyModuleDef_Slot astmodule_slots[] = {
12212 {Py_mod_exec, astmodule_exec},
12213 {0, NULL}
12214 };
12215
12216 static struct PyModuleDef _astmodule = {
12217 PyModuleDef_HEAD_INIT,
12218 .m_name = "_ast",
12219 // The _ast module uses a per-interpreter state (PyInterpreterState.ast)
12220 .m_size = 0,
12221 .m_slots = astmodule_slots,
12222 };
12223
12224 PyMODINIT_FUNC
12225 770 PyInit__ast(void)
12226 {
12227 770 return PyModuleDef_Init(&_astmodule);
12228 }
12229
12230
12231 3727 PyObject* PyAST_mod2obj(mod_ty t)
12232 {
12233 3727 struct ast_state *state = get_ast_state();
12234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3727 times.
3727 if (state == NULL) {
12235 return NULL;
12236 }
12237 3727 return ast2obj_mod(state, t);
12238 }
12239
12240 /* mode is 0 for "exec", 1 for "eval" and 2 for "single" input */
12241 mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode)
12242 {
12243 const char * const req_name[] = {"Module", "Expression", "Interactive"};
12244 int isinstance;
12245
12246 if (PySys_Audit("compile", "OO", ast, Py_None) < 0) {
12247 return NULL;
12248 }
12249
12250 struct ast_state *state = get_ast_state();
12251 if (state == NULL) {
12252 return NULL;
12253 }
12254
12255 PyObject *req_type[3];
12256 req_type[0] = state->Module_type;
12257 req_type[1] = state->Expression_type;
12258 req_type[2] = state->Interactive_type;
12259
12260 assert(0 <= mode && mode <= 2);
12261
12262 isinstance = PyObject_IsInstance(ast, req_type[mode]);
12263 if (isinstance == -1)
12264 return NULL;
12265 if (!isinstance) {
12266 PyErr_Format(PyExc_TypeError, "expected %s node, got %.400s",
12267 req_name[mode], _PyType_Name(Py_TYPE(ast)));
12268 return NULL;
12269 }
12270
12271 mod_ty res = NULL;
12272 if (obj2ast_mod(state, ast, &res, arena) != 0)
12273 return NULL;
12274 else
12275 return res;
12276 }
12277
12278 29231 int PyAST_Check(PyObject* obj)
12279 {
12280 29231 struct ast_state *state = get_ast_state();
12281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29231 times.
29231 if (state == NULL) {
12282 return -1;
12283 }
12284 29231 return PyObject_IsInstance(obj, state->AST_type);
12285 }
12286
12287
12288